How to use Conditional EVAL going to certain urls

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.

Moderators: Community Moderators, iMacros Moderators

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.

How to use Conditional EVAL going to certain urls

by a2515125 on Tue Jul 11, 2017 4:00 pm

hey,

my code is going to press 50 "like button" in one page (shopping website)

each category has 99 page.... (shoe/clothing/eletric/cosmetic thing....and so on)

Now my code can only run 99 pages in one category and it will stop......I want it to move next url to run another 99pages

there are more than 20 urls / 20 categories to run

I want my code to run 50times in a page x 99pages (4950 times)and go to the next URL or next category to run another 50*99 times button and go to next third url/category ..... in pure iim.

is it possible to use Eval statement to achieve it and how?


here is my code

Code: Select all
VERSION BUILD=8970419 RECORDER=FX
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0

'going to page
URL GOTO= URL1...2...3...4....5....100

TAB T=1
'set conditional statement that run 50 times to move next page

SET !VAR1 EVAL("var z=\"{{!LOOP}}\";z = (z % 50);if(z == 0){ z = 50};z=z++;")


'set loop to press like button

TAG POS={{!VAR1}} TYPE=PATH ATTR=D:m7.5<SP>4.2<SP>1.3-1.3c1.2-1.2<SP>3.1-1.2<SP>4.3<SP>0s1.2<SP>3.2<SP>0<SP>4.4l-5.6<SP>5.8-5.6-5.8c-1.2-1.2-1.2-3.2<SP>0-4.4s3.1-1.2<SP>4.3<SP>0z&&STROKE-LINEJOIN:round&&STROKE-MITERLIMIT:10&&STROKE-WIDTH:2&&TXT:


WAIT SECONDS=0.3

'move next page'
SET next EVAL("var x; var y=\"{{!LOOP}}\";if(y%50==0){x=1}else{x=0}; x;")

TAG POS={{next}}  TYPE=DIV ATTR=CLASS:shopee-icon-button<SP>shopee-icon-button--right<SP>



windows 10/ FF50.10 / imacro 8.9.7
a2515125
 
Posts: 84
Joined: Mon Dec 05, 2016 8:37 pm

Re: How to use Conditional EVAL going to certain urls

by chivracq on Tue Jul 11, 2017 8:51 pm

a2515125 wrote:
Code: Select all
windows 10/ FF50.10 / imacro 8.9.7
hey,

my code is going to press 50 "like button" in one page (shopping website)

each category has 99 page.... (shoe/clothing/eletric/cosmetic thing....and so on)

Now my code can only run 99 pages in one category and it will stop......I want it to move next url to run another 99pages

there are more than 20 urls / 20 categories to run

I want my code to run 50times in a page x 99pages (4950 times)and go to the next URL or next category to run another 50*99 times button and go to next third url/category ..... in pure iim.

is it possible to use Eval statement to achieve it and how?


here is my code

Code: Select all
VERSION BUILD=8970419 RECORDER=FX
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0

'going to page
URL GOTO= URL1...2...3...4....5....100

TAB T=1
'set conditional statement that run 50 times to move next page

SET !VAR1 EVAL("var z=\"{{!LOOP}}\";z = (z % 50);if(z == 0){ z = 50};z=z++;")


'set loop to press like button

TAG POS={{!VAR1}} TYPE=PATH ATTR=D:m7.5<SP>4.2<SP>1.3-1.3c1.2-1.2<SP>3.1-1.2<SP>4.3<SP>0s1.2<SP>3.2<SP>0<SP>4.4l-5.6<SP>5.8-5.6-5.8c-1.2-1.2-1.2-3.2<SP>0-4.4s3.1-1.2<SP>4.3<SP>0z&&STROKE-LINEJOIN:round&&STROKE-MITERLIMIT:10&&STROKE-WIDTH:2&&TXT:


WAIT SECONDS=0.3

'move next page'
SET next EVAL("var x; var y=\"{{!LOOP}}\";if(y%50==0){x=1}else{x=0}; x;")

TAG POS={{next}}  TYPE=DIV ATTR=CLASS:shopee-icon-button<SP>shopee-icon-button--right<SP>



windows 10/ FF50.10 / imacro 8.9.7

is it possible to use Eval statement to achieve it and how? .... in pure iim.

Yep it is, of course..., but hum..., not really willing to help too much for stupidly liking (= form of Spam for me, sorry...!) 5000 Users... :roll:
But you can always search the Forum for "Nested Loops"...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: How to use Conditional EVAL going to certain urls

by a2515125 on Thu Jul 13, 2017 5:23 am

it is a way that the website allow user to improve their products and they set the limit of likes of course....

anyway, thank you again :)
a2515125
 
Posts: 84
Joined: Mon Dec 05, 2016 8:37 pm

Re: How to use Conditional EVAL going to certain urls

by chivracq on Thu Jul 13, 2017 5:50 am

a2515125 wrote:it is a way that the website allow user to improve their products and they set the limit of likes of course....

anyway, thank you again :)

Oh yeah, I see, it's not liking Users but Products, and that for 100,000 Products... But if you want to run your Script for 100,000 Likes, it doesn't sound to me that "they" have set some Limit for 'Likes'...

But about "Nested Loops", your Case is about Nested Loops with 2 Levels of Nested Loops, you already have one Level nicely implemented in your Script with 2 perfect Examples, it's not very-very difficult to add the 2nd Level...

Even if hum..., that 2nd Level is not really arithmetic I guess, then you cannot compute it with a 'Modulo' Math Function with 'EVAL()' but you need to base it on extracting some Element which is present (or not anymore) once you've reached the end of the Pages for one URL before switching to the next URL.
It's the same Principle like for a "Conditional 'REFRESH'" which actually cannot be done (easily) in pure '.iim' but is achieved by doing a "Conditional 'URL GOTO'", and that's exactly what you want... Several Threads on the Forum...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: How to use Conditional EVAL going to certain urls

by a2515125 on Thu Jul 13, 2017 7:50 am

that is right

I am struggling with conditional refresh /conditional url goto :oops: :oops: :oops:

it is very often to meet the requirement of conditional url goto ...........Orzzz
a2515125
 
Posts: 84
Joined: Mon Dec 05, 2016 8:37 pm

Re: How to use Conditional EVAL going to certain urls

by a2515125 on Thu Jul 13, 2017 8:59 am

i saw you use eval with if x=1 excute the code, else x=0

however, I use this technique on conditional URL GO TO, it fails

I want to go certain url or different urls like http://www.google.com after the script loop 5 times

my code cannot go to the certain url after loop 5 and I dont know how to make it do nothing when loop 1-4 times

because loop 1-4 it keeps navigate to www.0.com :oops: :oops: :oops:





here is my code

Code: Select all
SET !REPLAYSPEED FAST
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET !TIMEOUT_STEP 0

SET !LOOP

SET reload EVAL("var x; var y=\"{{!LOOP}}\";if(y%5==0){x=WWW.GOOGLE.COM}else{x=0}; x;")
URL GOTO={{reload}}


a2515125
 
Posts: 84
Joined: Mon Dec 05, 2016 8:37 pm

Re: How to use Conditional EVAL going to certain urls

by chivracq on Thu Jul 13, 2017 9:24 am

a2515125 wrote:i saw you use eval with if x=1 excute the code, else x=0

however, I use this technique on conditional URL GO TO, it fails

I want to go certain url or different urls like http://www.google.com after the script loop 5 times

my code cannot go to the certain url after loop 5 and I dont know how to make it do nothing when loop 1-4 times

because loop 1-4 it keeps navigate to http://www.0.com :oops: :oops: :oops:

here is my code

Code: Select all
SET !REPLAYSPEED FAST
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET !TIMEOUT_STEP 0

SET !LOOP

SET reload EVAL("var x; var y=\"{{!LOOP}}\";if(y%5==0){x=WWW.GOOGLE.COM}else{x=0}; x;")
URL GOTO={{reload}}

I spit out a '1'/'0' with 'EVAL()' to reuse for 'POS=n', because 'POS' expects a Number, I could spit out '1'/'99999' instead...
'URL GOTO' expects a String, then you are on the right Path but I'm not sure the Browser will like a "URL GOTO=0", ah-ah...!, I know it works with an empty String:
Code: Select all
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET !TIMEOUT_STEP 0

SET reload EVAL("var x; var y=\"{{!LOOP}}\"; if(y%5==0){x='www.google.com';} else{x='';}; x;")
URL GOTO={{reload}}


EDIT: Oops, 2 Typos in the 'EVAL()', 2x missing ';'... :oops: (Corrected...)
Last edited by chivracq on Thu Jul 13, 2017 12:28 pm, edited 1 time in total.
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: How to use Conditional EVAL going to certain urls

by a2515125 on Thu Jul 13, 2017 12:05 pm

thanks it works.... you are really imacro pro :))

but I would like to know if it can insert urls from csv file .......like this one


SET reload EVAL("var x; var y=\"{{!LOOP}}\"; if(y%5==0){x={{!COL1}}} else{x=''}; x;")
URL GOTO={{reload}}
a2515125
 
Posts: 84
Joined: Mon Dec 05, 2016 8:37 pm

Re: How to use Conditional EVAL going to certain urls

by chivracq on Thu Jul 13, 2017 12:39 pm

a2515125 wrote:thanks it works.... you are really imacro pro :))

but I would like to know if it can insert urls from csv file .......like this one

Code: Select all
SET reload EVAL("var x; var y=\"{{!LOOP}}\"; if(y%5==0){x=[color=#FF0000]{{!COL1}}}[/color] else{x=''}; x;")
URL GOTO={{reload}}

Oops, 2x Typos in my previous Post in the 'EVAL()' Statement, corrected now...

But if my Syntax still worked, even with the Typos, then yours should work as well, but maybe safer is this one:
Code: Select all
SET reload EVAL("var x, y='{{!LOOP}}', url='{{!COL1}}'; if(y%5==0){x=url;} else{x='';}; x;")
URL GOTO={{reload}}
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: How to use Conditional EVAL going to certain urls

by a2515125 on Thu Jul 13, 2017 1:33 pm

thanks...

you open my vision of how to use eval experssion in pure iim

eval express seems very often to see in pure iim script
a2515125
 
Posts: 84
Joined: Mon Dec 05, 2016 8:37 pm

Re: How to use Conditional EVAL going to certain urls

by chivracq on Thu Jul 13, 2017 2:38 pm

a2515125 wrote:thanks...

you open my vision of how to use eval experssion in pure iim

eval express seems very often to see in pure iim script

Well, I was the first to do "everything" in pure '.iim' I think, with complete Conditional Logic, only because I wanted to avoid '.js' Scripts (if possible of course, otherwise I would have finally diven into JS, but I was always "Creative" enough to always find Solutions/Workarounds in pure '.iim' ah-ah...!), but I indeed see since about 2 years many other (Advanced) Users following "my" Path, even if those Users are usually very "fluent" in JS as well, so I guess my Method was not that bad, ah-ah...!
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: How to use Conditional EVAL going to certain urls

by a2515125 on Fri Jul 14, 2017 8:20 am

I was trying to run two js at the same time when I did not know how to code in iim but imacros or firefox seems not allow me to do so.....

whenever I run two js, imacros freezes immediately

so I prefer to use pure iim to run several task at the same time...that is why...haha

pure iim is more complex if users like me not familiar with coding or imacros syntax or conditional syntax like eval

=============================================================


I got another problem and cannot figure out what is wrong :((

I want to press the first category (total categories =20)and press 16 sub-categories of first category and go back url

to press second category and then press 16 sub-categories of second category and go back url
.
.
.
until press 20th category

=============================================================




However, when I put them together (FIRST PART + SECOND+THIRD PART) in one iim script,

iMacros presses/runs POS= 1/17/14/11/8/5/2/19/16/13/10/7/4.................

according to my code, it supposed to be POS=1/2/3/4......20
isn't it?


how can I fix this ?




total code
Code: Select all

SET !REPLAYSPEED FAST
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET !TIMEOUT_STEP 0



'17 loops going back to url--------first part
SET !VAR2 EVAL("var x; var y=\"{{!LOOP}}\";if(y%17==0){x='https://shopee.tw/'}else{x=''}; x;")
URL GOTO={{!VAR2}}
WAIT SECONDS=0.3

'after 20 loops going to different categories----------second part
SET !VAR1 EVAL("var z=\"{{!LOOP}}\";z = (z % 20);if(z == 0){ z = 20};z=z++;")

TAG POS={{!VAR1}} TYPE=DIV ATTR=CLASS:home-category-list__category-grid-thumbnail&&TXT:
WAIT SECONDS=0.3


'set loops to run different subcategory------------third part
SET !VAR4 EVAL("var z=\"{{!LOOP}}\";z = (z % 16);if(z == 0){ z = 16};z=z++;")

'extract the txt and reuse it
TAG POS={{!VAR4}} TYPE=A ATTR=CLASS:shopee-category-list__sub-category EXTRACT=TXT

a2515125
 
Posts: 84
Joined: Mon Dec 05, 2016 8:37 pm

Re: How to use Conditional EVAL going to certain urls

by a2515125 on Fri Jul 14, 2017 9:27 pm

delete .....
Last edited by a2515125 on Fri Jul 14, 2017 9:34 pm, edited 1 time in total.
a2515125
 
Posts: 84
Joined: Mon Dec 05, 2016 8:37 pm

Re: How to use Conditional EVAL going to certain urls

by a2515125 on Fri Jul 14, 2017 9:29 pm

chivracq wrote:
a2515125 wrote:thanks it works.... you are really imacro pro :))

but I would like to know if it can insert urls from csv file .......like this one

Code: Select all
SET reload EVAL("var x; var y=\"{{!LOOP}}\"; if(y%5==0){x=[color=#FF0000]{{!COL1}}}[/color] else{x=''}; x;")
URL GOTO={{reload}}

Oops, 2x Typos in my previous Post in the 'EVAL()' Statement, corrected now...

But if my Syntax still worked, even with the Typos, then yours should work as well, but maybe safer is this one:
Code: Select all
SET reload EVAL("var x, y='{{!LOOP}}', url='{{!COL1}}'; if(y%5==0){x=url;} else{x='';}; x;")
URL GOTO={{reload}}



Firstly,thanks for showing the code of reload

I guess it means
URL GOTO={{reload}} will navigate to urls
from csv after !LOOP N

BUT after I tested it last night
this code fails to go !COL 1/ !COL 2/ !COL 3........after every 10 loops
instead, it navigates to !COL10/ !COL20/ !COL30........ after reaching every 10 loops

it seems url='{{!COL1}}' not working as it should be

how can we let URL GOTO={{reload}} go !COL 1/ !COL 2/ !COL 3........after every 10 loops ?


Code: Select all
VERSION BUILD=8970419 RECORDER=FX
SET !REPLAYSPEED FAST
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
SET !DATASOURCE C:\Users\a2515125\Desktop\iMacroscript\URLS.csv

TAB T=1

SET reload EVAL("var x; y='{{!LOOP}}'; url='{{!COL1}}'; if(y%10==0){x=url;} else{x='';}; x;")

URL GOTO={{reload}}


a2515125
 
Posts: 84
Joined: Mon Dec 05, 2016 8:37 pm

Re: How to use Conditional EVAL going to certain urls

by chivracq on Sat Jul 15, 2017 6:18 am

a2515125 wrote:I was trying to run two js at the same time when I did not know how to code in iim but imacros or firefox seems not allow me to do so.....

whenever I run two js, imacros freezes immediately

so I prefer to use pure iim to run several task at the same time...that is why...haha

pure iim is more complex if users like me not familiar with coding or imacros syntax or conditional syntax like eval

=============================================================


I got another problem and cannot figure out what is wrong :((

I want to press the first category (total categories =20)and press 16 sub-categories of first category and go back url

to press second category and then press 16 sub-categories of second category and go back url
.
.
.
until press 20th category

=============================================================


However, when I put them together (FIRST PART + SECOND+THIRD PART) in one iim script,

iMacros presses/runs POS= 1/17/14/11/8/5/2/19/16/13/10/7/4.................

according to my code, it supposed to be POS=1/2/3/4......20
isn't it?


how can I fix this ?

total code
Code: Select all
SET !REPLAYSPEED FAST
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET !TIMEOUT_STEP 0

'17 loops going back to url--------first part
SET !VAR2 EVAL("var x; var y=\"{{!LOOP}}\";if(y%17==0){x='https://shopee.tw/'}else{x=''}; x;")
URL GOTO={{!VAR2}}
WAIT SECONDS=0.3

'after 20 loops going to different categories----------second part
SET !VAR1 EVAL("var z=\"{{!LOOP}}\";z = (z % 20);if(z == 0){ z = 20};z=z++;")

TAG POS={{!VAR1}} TYPE=DIV ATTR=CLASS:home-category-list__category-grid-thumbnail&&TXT:
WAIT SECONDS=0.3

'set loops to run different subcategory------------third part
SET !VAR4 EVAL("var z=\"{{!LOOP}}\";z = (z % 16);if(z == 0){ z = 16};z=z++;")

'extract the txt and reuse it
TAG POS={{!VAR4}} TYPE=A ATTR=CLASS:shopee-category-list__sub-category EXTRACT=TXT

Hum, about the 2 '.js' Scripts "blocking" each other, this could be related to this other Thread, which doesn't contain much Info, I asked twice that User to post some Update but they didn't follow up anymore...

I didn't go digging into your Script for this Post...

a2515125 wrote:Firstly,thanks for showing the code of reload

I guess it means
URL GOTO={{reload}} will navigate to urls
from csv after !LOOP N

BUT after I tested it last night
this code fails to go !COL 1/ !COL 2/ !COL 3........after every 10 loops
instead, it navigates to !COL10/ !COL20/ !COL30........ after reaching every 10 loops

it seems url='{{!COL1}}' not working as it should be

how can we let URL GOTO={{reload}} go !COL 1/ !COL 2/ !COL 3........after every 10 loops ?

Code: Select all
VERSION BUILD=8970419 RECORDER=FX
SET !REPLAYSPEED FAST
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
SET !DATASOURCE C:\Users\a2515125\Desktop\iMacroscript\URLS.csv

TAB T=1

SET reload EVAL("var x; y='{{!LOOP}}'; url='{{!COL1}}'; if(y%10==0){x=url;} else{x='';}; x;")

URL GOTO={{reload}}

Yep, normal, '!COL1' uses '!LOOP' to know from which Row it needs to fetch the Data in Col_1... You then need to compute '!DATASOURCE_LINE' based on '!LOOP', by simply dividing '!LOOP' by 10, I would think...
Last edited by chivracq on Mon Jul 17, 2017 12:50 pm, edited 1 time in total.
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Next

Return to General Support & Discussions

Who is online

Users browsing this forum: Google [Bot] and 8 guests

-->