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 Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

EVAL If not returning value

by techimac on Wed May 02, 2018 4: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
techimac
 
Posts: 279
Joined: Fri Feb 20, 2015 2:27 pm

Re: EVAL If not returning value

by thecoder2012 on Wed May 02, 2018 5:28 pm

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!
User avatar
thecoder2012
 
Posts: 248
Joined: Sat Aug 15, 2015 10:14 am
Location: Internet

Re: EVAL If not returning value

by techimac on Wed May 02, 2018 6:03 pm

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: 279
Joined: Fri Feb 20, 2015 2:27 pm

Re: EVAL If not returning value

by techimac on Wed May 02, 2018 6:14 pm

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}}
techimac
 
Posts: 279
Joined: Fri Feb 20, 2015 2:27 pm

Re: EVAL If not returning value

by thecoder2012 on Wed May 02, 2018 6:44 pm

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!
User avatar
thecoder2012
 
Posts: 248
Joined: Sat Aug 15, 2015 10:14 am
Location: Internet

Re: EVAL If not returning value

by techimac on Wed May 02, 2018 10:48 pm

Thanks.
I need logic to find a word on web page.
techimac
 
Posts: 279
Joined: Fri Feb 20, 2015 2:27 pm

Re: EVAL If not returning value

by thecoder2012 on Thu May 03, 2018 1: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!
User avatar
thecoder2012
 
Posts: 248
Joined: Sat Aug 15, 2015 10:14 am
Location: Internet


Return to Command Line and Scripting Interface

Who is online

Users browsing this forum: No registered users and 3 guests

-->