Yep, there will always be some misunderstanding if I cannot play myself with the Page, as I mentioned... iMacros heavily depends on the HTML Structure of a Page, as soon as stg changes on the Page, you have to adapt your Script. You make it generic, but but you need to investigate what changes/remains constant, like I've said already... But I gave you the Method and there is no difficulty to apply it to your 2nd Example:
In the first Example you gave, the HTM Extract returned:
Code: Select all
<body style="outline: 1px solid blue;"> <table></table> <h4></h4> <br><br> the leaves on this tree are green <br><br> </body>
The Data you are looking for is surrounded before and after by "<br><br>", so I just used a Double 'split()' on that String:
Code: Select all
SET Extracted_Sentence EVAL("var s='{{!EXTRACT}}'; var x; x=s.split('<br><br>'); x[1];")
PROMPT Extracted_Sentence:<BR>_{{Extracted_Sentence}}_
In your 2nd Example, the HTM Extract returns:
Code: Select all
<body style="outline: 1px solid blue;"> <h4>Title</h4> <br> the leaves on this tree are green<br> <font color="green">some other text</font><br><br> <table></table> </body>
The Data/Sentence you are after is now surrounded by only 1 "<b>" before and after, and it's still the 2nd Occurrence of a 'split()' on "<br>", then you just need to remove 1 "<br>" in the 'split()':
Code: Select all
SET Extracted_Sentence EVAL("var s='{{!EXTRACT}}'; var x; x=s.split('<br>'); x[1];")
PROMPT Extracted_Sentence:<BR>_{{Extracted_Sentence}}_
Full Script:
Code: Select all
VERSION BUILD=8820413 RECORDER=FX
TAB T=1
URL GOTO=file:///C:/Users/Admin/Desktop/Green%20Leaves_2.htm
TAG POS=1 TYPE=BODY ATTR=* EXTRACT=HTM
'=> Extracted Text: "<body style="outline: 1px solid blue;"> <h4>Title</h4> <br> the leaves on this tree are green<br> <font color="green">some other text</font><br><br> <table></table> </body>"
SET Extracted_Sentence EVAL("var s='{{!EXTRACT}}'; var x; x=s.split('<br>'); x[1];")
PROMPT Extracted_Sentence:<BR>_{{Extracted_Sentence}}_
(Tested on iMacros for FF v8.8.2, PM v24.6.2, Win7-x64.)
Tested on this File:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...