EVAL If not returning value

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
techimac
Posts: 293
Joined: Fri Feb 20, 2015 9:27 pm

EVAL If not returning value

Post by techimac » Wed May 02, 2018 11:50 pm

TAG POS=1 TYPE=A ATTR=TXT:*offered* EXTRACT=TXT


SET key EVAL("var s='{{!EXTRACT}}'; var x; if(s!='#EANF#'){ x=\"YES\";} x")

prompt {{key}}

I am getting _undefined_ when text is extracted
need help fast
User avatar
thecoder2012
Posts: 358
Joined: Sat Aug 15, 2015 5:14 pm
Location: Internet
Contact:

Re: EVAL If not returning value

Post by thecoder2012 » Thu May 03, 2018 12:28 am

techimac wrote:TAG POS=1 TYPE=A ATTR=TXT:*offered* EXTRACT=TXT
Website url or (full) html code? (full example)
techimac wrote:SET key EVAL("var s='{{!EXTRACT}}'; var x; if(s!='#EANF#'){ x=\"YES\";} x")
prompt {{key}}

I am getting _undefined_ when text is extracted
need help fast
I have no "__undefined__" in my tests with your script.
Tested with iMacros 8.9.7, Win8.1 and Waterfox 55.

But why no "else"? Like:

Code: Select all

SET key EVAL("var s='{{!EXTRACT}}'; var x; if(s!='#EANF#'){ x=\"YES\";}else{x=\"\";}; x")
prompt {{key}}
My test html code:

Code: Select all

<a>mega offered thing</a>
Join 9kw.eu Captcha Service now and let your iMacros continue downloads and scripts while you sleep. - Custom iMacros? Contact me! :idea:
techimac
Posts: 293
Joined: Fri Feb 20, 2015 9:27 pm

Re: EVAL If not returning value

Post by techimac » Thu May 03, 2018 1:03 am

try this

TAG POS=1 TYPE=* ATTR=TXT:*offered* EXTRACT=TXT
SET key EVAL("var s='{{!EXTRACT}}'; var x; if(s!='#EANF#'){ x=\"YES\";} x")

prompt {{key}}
techimac
Posts: 293
Joined: Fri Feb 20, 2015 9:27 pm

Re: EVAL If not returning value

Post by techimac » Thu May 03, 2018 1:14 am

can you fix this?
and
TAG POS=1 TYPE=* ATTR=TXT:*iphone* EXTRACT=txt seems to hang browser

set !errorignore yes
SET !TIMEOUT_PAGE 10
url goto=google.com
SET !TIMEOUT_PAGE 1
wait seconds=5
TAG POS=1 TYPE=* ATTR=TXT:*iphone* EXTRACT=txt
SET key EVAL("var s='{{!EXTRACT}}'; var x; if(s!='#EANF#'){ x=\"YES\";}else{x=\"\";}; x")
prompt {{key}}
User avatar
thecoder2012
Posts: 358
Joined: Sat Aug 15, 2015 5:14 pm
Location: Internet
Contact:

Re: EVAL If not returning value

Post by thecoder2012 » Thu May 03, 2018 1:44 am

techimac wrote:can you fix this?
Not with pure EVAL. Workarounds possible (textarea, javascript, second tab) or more Javascript (as *.js file). Clean up your html code.
techimac wrote:

Code: Select all

set !errorignore yes
SET !TIMEOUT_PAGE 10
url goto=google.com
SET !TIMEOUT_PAGE 1
wait seconds=5
TAG POS=1 TYPE=* ATTR=TXT:*iphone* EXTRACT=txt
SET key EVAL("var s='{{!EXTRACT}}'; var x; if(s!='#EANF#'){ x=\"YES\";}else{x=\"\";}; x")
prompt {{key}}
EVAL failed. Your problem is the content in {{!EXTRACT}} because it's HTML-Code.
Errormessage: SyntaxError: unterminated string literal, line 7 (Error code: -1001) (set errorignore to NO)
Join 9kw.eu Captcha Service now and let your iMacros continue downloads and scripts while you sleep. - Custom iMacros? Contact me! :idea:
techimac
Posts: 293
Joined: Fri Feb 20, 2015 9:27 pm

Re: EVAL If not returning value

Post by techimac » Thu May 03, 2018 5:48 am

Thanks.
I need logic to find a word on web page.
User avatar
thecoder2012
Posts: 358
Joined: Sat Aug 15, 2015 5:14 pm
Location: Internet
Contact:

Re: EVAL If not returning value

Post by thecoder2012 » Thu May 03, 2018 8:30 am

techimac wrote:I need logic to find a word on web page.
See https://wiki.imacros.net/SEARCH

Small example with Textarea and Javascript as workaround:

Code: Select all

SET !TIMEOUT_PAGE 10
URL GOTO=google.com
SET !TIMEOUT_PAGE 1
WAIT SECONDS=5
TAG POS=1 TYPE=* ATTR=TXT:*iphone* EXTRACT=TXT
URL GOTO=javascript:var<SP>input<SP>=<SP>document.createElement('textarea');input.id="xyz";document.body.appendChild(input);document.focus();
TAG POS=1 TYPE=TEXTAREA ATTR=ID:xyz CONTENT={{!EXTRACT}}
SET !EXTRACT NULL
URL GOTO=javascript:document.getElementById("xyz").value=encodeURIComponent(document.getElementById("xyz").value.replace("'").replace('"'));document.focus();
TAG POS=1 TYPE=TEXTAREA ATTR=ID:xyz EXTRACT=TXT
URL GOTO=javascript:var<SP>node=document.getElementById('xyz');node.parentNode.removeChild(node);document.focus();
SET key EVAL("var s='{{!EXTRACT}}'; var x; if(s!='#EANF#'){ x=\"YES\";}else{x=\"\";}; x")
PROMPT {{key}}
Join 9kw.eu Captcha Service now and let your iMacros continue downloads and scripts while you sleep. - Custom iMacros? Contact me! :idea:
Post Reply