Skip to content Skip to sidebar Skip to footer

How To Extract Specific Text With Imacros Xpath

I have this code in a website:
  • text I want to extract text I don't want to extract
  • I'm using t

    Solution 1:

    For your Specific case Shugar's code with some tweaking will work. Split \n and extract [1] :

    TAG XPATH="id('1234')/li[1]" EXTRACT=TXT
    SET !EXTRACT EVAL("'{{!EXTRACT}}'.split('\\n')[1];")
    PROMPT {{!EXTRACT}}
    

    If you want a more General approach you can get li[1] and split by content of span at [0]:

    TAGXPATH="id('1234')/li[1]"EXTRACT=TXTSET!VAR1 {{!EXTRACT}}
    SET!EXTRACTNULLTAGXPATH="id('1234')/li[1]/span"EXTRACT=TXTSET!EXTRACTEVAL("'{{!VAR1}}'.split('{{!EXTRACT}}')[0];")PROMPT {{!EXTRACT}}
    

    Solution 2:

    I suggest just adding one more line in your code:

    TAG XPATH="id('1234')/li[1]" EXTRACT=TXT
    SET !EXTRACT EVAL("'{{!EXTRACT}}'.split('<span>')[0];")

    Post a Comment for "How To Extract Specific Text With Imacros Xpath"