how to loop iim script automatically with windows scheduler

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

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
a2515125
Posts: 114
Joined: Tue Dec 06, 2016 3:37 am

how to loop iim script automatically with windows scheduler

Post by a2515125 » Sat Aug 25, 2018 2:43 am

windows 10/imcros 8.9.7/FF 50.1

Hey, I want to let my iim. script to extract the data from website with windows scheduler everyday..

however, i find out that my bat file launch the iim scrpt only run one time and then stop!

Therefore I would like to know how to do it loops in iim script when trigger the bat file.

my iim script need to loops in two part

1.
main loop 1-99999
2.
every main loop to extract 1-40 item then press "next page"
due to the website encrypts the link page that I cannot use js to count to turn next page :oops:

I would appreciate if anyone has any idea........to fix my problem.....thanks first

bat script

Code: Select all


@echo off

start firefox.exe -P default -no-remote imacros://run/?m=123\123\123.iim

iim script

Code: Select all

SET !REPLAYSPEED FAST
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 3
SET !TIMEOUT_STEP 0
SET !LOOP 1

'extract url'
WAIT SECONDS=0.02
'set loop to scrape'
FILTER TYPE=IMAGES STATUS=OFF

'auto loading website one time then keep pressing next page button to turn pages
SET reload EVAL("var x; y='{{!LOOP}}'; url='***********************************?sort_by=time_created%2Cdescending&collection_id=1243&cc_id=1645'; if(y==1){x=url;} else{x='';}; x;")
URL GOTO={{reload}}


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

'extract data
TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-i 
TAG POS={{!VAR1}} TYPE=dl ATTR=CLASS:* EXTRACT=htm
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('<dd>');y= x[1].split('</dd>'),z=y[0]; z;")
ADD Temp_Extract {{!VAR2}}
SET !EXTRACT {{!VAR2}}
TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-l EXTRACT=TXT
TAG POS={{!VAR1}} TYPE=TIME ATTR=CLASS:*-r<SP>*-w EXTRACT=TXT 
TAG POS={{!VAR1}} TYPE=A ATTR=CLASS:*-g<SP>media EXTRACT=HREF 


'NEXT PAGE condition'
SET next EVAL("var x; var y=\"{{!LOOP}}\";if(y%40==0){x=1}else{x=0}; x;")
'next page button'
TAG POS={{next}}  TYPE=SPAN ATTR=TXT:Next<SP>Page

SAVEAS TYPE=EXTRACT FOLDER=C:\Users\admin\Desktop\iMacroscript FILE=XXXX.csv

SET wait EVAL("var x; var y=\"{{!LOOP}}\";if(y%40==0){x=5}else{x=0}; x;")
WAIT SECONDS={{wait}}

'auto close firefox
TAG POS=1 TYPE=A ATTR=CLASS:DISABLED EXTRACT=TXT
SET CLOSE_FIREFOX EVAL("var s='{{!EXTRACT}}'; if(s=='Next Page') {var x='\"ctrl,shift\"';} else{var x='';} x;")
EVENT TYPE=KEYPRESS SELECTOR=* CHAR="w" MODIFIERS={{CLOSE_FIREFOX}}
SET !EXTRACT NULL



chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: how to loop iim script automatically with windows schedu

Post by chivracq » Sat Aug 25, 2018 11:28 am

a2515125 wrote:

Code: Select all

windows 10/imcros 8.9.7/FF 50.1
Hey, I want to let my iim. script to extract the data from website with windows scheduler everyday..

however, i find out that my bat file launch the iim scrpt only run one time and then stop!

Therefore I would like to know how to do it loops in iim script when trigger the bat file.

my iim script need to loops in two part

1.
main loop 1-99999
2.
every main loop to extract 1-40 item then press "next page"
due to the website encrypts the link page that I cannot use js to count to turn next page :oops:

I would appreciate if anyone has any idea........to fix my problem.....thanks first

bat script

Code: Select all

@echo off

start firefox.exe -P default -no-remote imacros://run/?m=123\123\123.iim
iim script

Code: Select all

SET !REPLAYSPEED FAST
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 3
SET !TIMEOUT_STEP 0
SET !LOOP 1

'extract url'
WAIT SECONDS=0.02
'set loop to scrape'
FILTER TYPE=IMAGES STATUS=OFF

'auto loading website one time then keep pressing next page button to turn pages
SET reload EVAL("var x; y='{{!LOOP}}'; url='***********************************?sort_by=time_created%2Cdescending&collection_id=1243&cc_id=1645'; if(y==1){x=url;} else{x='';}; x;")
URL GOTO={{reload}}


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

'extract data
TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-i 
TAG POS={{!VAR1}} TYPE=dl ATTR=CLASS:* EXTRACT=htm
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('<dd>');y= x[1].split('</dd>'),z=y[0]; z;")
ADD Temp_Extract {{!VAR2}}
SET !EXTRACT {{!VAR2}}
TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-l EXTRACT=TXT
TAG POS={{!VAR1}} TYPE=TIME ATTR=CLASS:*-r<SP>*-w EXTRACT=TXT 
TAG POS={{!VAR1}} TYPE=A ATTR=CLASS:*-g<SP>media EXTRACT=HREF 


'NEXT PAGE condition'
SET next EVAL("var x; var y=\"{{!LOOP}}\";if(y%40==0){x=1}else{x=0}; x;")
'next page button'
TAG POS={{next}}  TYPE=SPAN ATTR=TXT:Next<SP>Page

SAVEAS TYPE=EXTRACT FOLDER=C:\Users\admin\Desktop\iMacroscript FILE=XXXX.csv

SET wait EVAL("var x; var y=\"{{!LOOP}}\";if(y%40==0){x=5}else{x=0}; x;")
WAIT SECONDS={{wait}}

'auto close firefox
TAG POS=1 TYPE=A ATTR=CLASS:DISABLED EXTRACT=TXT
SET CLOSE_FIREFOX EVAL("var s='{{!EXTRACT}}'; if(s=='Next Page') {var x='\"ctrl,shift\"';} else{var x='';} x;")
EVENT TYPE=KEYPRESS SELECTOR=* CHAR="w" MODIFIERS={{CLOSE_FIREFOX}}
SET !EXTRACT NULL
Hum, iMacros v8.9.7 + FF50 is a "clever" FCI indeed if you are using the 'FILTER' Command, I think it still works until FF51 (with v8.9.7) but got broken in FF52 or FF53 (I don't know exactly from which FF Version as I had updated at that time directly from FF51 to FF53)...
You should btw reset 'FILTER' at the end of your Script as it doesn't automatically get reset... Ah no, sorry...!, you don't use it actually, it is already set to 'OFF'...

OK, your whole Script is a bit of a "Collection" of several Techniques and Tricks and using different Syntaxes (I recognize "my Style" in a few places, ah-ah...!), you should "harmonize" it a little bit and just adopt only one single Syntax (especially within 'EVAL()') that you understand best, or I deduct that you don't really understand what your Script is doing exactly... :o

Nice Trick btw with the 'Ctrl^Shift^w' to close FF conditionally, I don't think I knew this FF Shortcut, I only knew 'Alt^F4', which doesn't work with the 'EVENT' Mode, this 'Ctrl^Shift^w' is better, ah-ah...! 8)

But OK, to answer your Qt, first I don't really understand your "due to the website encrypts the link page that I cannot use js to count to turn next page", I don't know what "encrypting a Link" means, the half-truncated URL you've left in one of your 'EVAL()''s looks pretty straightforward with 2 URL Params that probably get incremented on each next Page...

But anyway, if you can loop your '.iim' Macro with the Side-Panel 'Loop' Functionality, you can always loop the same Macro from a '.js' Script, it is using the exact same Mechanism. The only Difference is that you are not limited to "99999" from a '.js' Script like in the Side-Panel... Hum, and you have (more) Control on the '!LOOP_MAX' Var... which doesn't exist anyway, grrr...!!
But you need to handle the Looping yourself, first from the '.js' Script, and then again inside the '.iim' Script to use the Looping from the '.js' Script, you cannot use '!LOOP' anymore... (Many Examples on the Forum...)

There is a Trick that can be used to loop directly an '.iim' Macro launched from a '.BAT' File and/or from the Scheduler (that I use myself), and I "normally" don't "like" (or didn't want) to "advertize "too much" about it as it relies on a mini-Bug and I was afraid it would get "fixed" one day in some later Version, but several (semi-)Advanced Users kept posting about it in the past against my "Advice", and the Loop Mechanism got completely rewritten in v10.2 for FF and is now limited to 100 Loops in the 'Free' Version, so I guess this Trick doesn't work anymore in v10.2 anyway... :(
=> Search the Forum for "Negative Loop/Looping" if you want more Info...
But even with using this Trick, you will very probably need to "rethink" the Logic of your '.iim' Script as you based several 'EVAL()' Statements on the raw/native '!LOOP', your Modulo[40] for example to move to the next Page, as that Functionality might get broken... (=> You'll have 2.5% Chances it will still work correctly, and 97.5% Chances it won't work anymore, ah-ah...!, once you'll have understood how that Mechanism works... :wink: )
- (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...
a2515125
Posts: 114
Joined: Tue Dec 06, 2016 3:37 am

Re: how to loop iim script automatically with windows schedu

Post by a2515125 » Mon Aug 27, 2018 5:13 pm

hey chivracq

good to hear from you again. ^^

here is the website URL that I call encrypted urls which makes it harder to use js code to turn next page
* means same words

first page url=
https://*

second page url=
https://*&session=eyJhZ2dyZWdhdGVfY291bnQiOjQwLCJzZXNzaW9uX2luaXRfYXQiOiIyMDE4LTA4LTI3VDE3OjA0OjU0LjY5ODMxNzg1NVoiLCJzaWduYXR1cmVfaGFzaCI6Iis1RGg4cEtWV3FpMHpMV1F5VFVpTTZkSkZDWT0iLCJzbG90cyI6eyJkZWZhdWx0Ijp7Im9mZnNldF90aW1lIjoiMjAxOC0wOC0yNyAxNDo0MzoxNC43NDIwMDArMDA6MDAifSwiZmlyc3RfdGltZV9saXN0ZXIiOnsib2Zmc2V0X3RpbWUiOiIyMDE4LTA4LTI3IDExOjM1OjI2LjQ1NTAwMCswMDowMCJ9fX0%3D

third page url=
https://*&session=eyJhZ2dyZWdhdGVfY291bnQiOjgwLCJzZXNzaW9uX2luaXRfYXQiOiIyMDE4LTA4LTI3VDE3OjA0OjU0LjY5ODMxNzg1NVoiLCJzaWduYXR1cmVfaGFzaCI6Iis1RGg4cEtWV3FpMHpMV1F5VFVpTTZkSkZDWT0iLCJzbG90cyI6eyJkZWZhdWx0Ijp7Im9mZnNldF90aW1lIjoiMjAxOC0wOC0yNyAxMzo1Mzo1MS4wMTEwMDArMDA6MDAifSwiZmlyc3RfdGltZV9saXN0ZXIiOnsib2Zmc2V0X3RpbWUiOiIyMDE4LTA4LTI3IDA5OjAyOjM5LjQyMzAwMCswMDowMCJ9fX0%3D

forth page url=
https://*&session=eyJhZ2dyZWdhdGVfY291bnQiOjEyMCwic2Vzc2lvbl9pbml0X2F0IjoiMjAxOC0wOC0yN1QxNzowNDo1NC42OTgzMTc4NTVaIiwic2lnbmF0dXJlX2hhc2giOiIrNURoOHBLVldxaTB6TFdReVRVaU02ZEpGQ1k9Iiwic2xvdHMiOnsiZGVmYXVsdCI6eyJvZmZzZXRfdGltZSI6IjIwMTgtMDgtMjcgMTI6MjI6MDAuNjEzMDAwKzAwOjAwIn0sImZpcnN0X3RpbWVfbGlzdGVyIjp7Im9mZnNldF90aW1lIjoiMjAxOC0wOC0yNyAwNzoyOToyOC4wOTEwMDArMDA6MDAifX19

---------------------------------------
The turn page and waiting time work as they should be when I put negative !loop on my script
However, it does not work for my Eval statement to extract data at all... :idea:
it seems that eval statement could not recognize the negative loop

do you have any idea to fix/improve my eval statement?

Code: Select all


SET !VAR1 EVAL("var z=\"{{!LOOP}}\";z = (z % 40);if(z == 0){ z = 40};z=z++;")
'extract data
TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-i 
TAG POS={{!VAR1}} TYPE=dl ATTR=CLASS:* EXTRACT=htm
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('<dd>');y= x[1].split('</dd>'),z=y[0]; z;")
ADD Temp_Extract {{!VAR2}}
SET !EXTRACT {{!VAR2}}
TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-l EXTRACT=TXT
TAG POS={{!VAR1}} TYPE=TIME ATTR=CLASS:*-r<SP>*-w EXTRACT=TXT 
TAG POS={{!VAR1}} TYPE=A ATTR=CLASS:*-g<SP>media EXTRACT=HREF
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: how to loop iim script automatically with windows schedu

Post by chivracq » Mon Aug 27, 2018 7:34 pm

a2515125 wrote:hey chivracq

good to hear from you again. ^^

here is the website URL that I call encrypted urls which makes it harder to use js code to turn next page
* means same words

first page url=
https://*

second page url=
https://*&session=eyJhZ2dyZWdhdGVfY291bnQiOjQwLCJzZXNzaW9uX2luaXRfYXQiOiIyMDE4LTA4LTI3VDE3OjA0OjU0LjY5ODMxNzg1NVoiLCJzaWduYXR1cmVfaGFzaCI6Iis1RGg4cEtWV3FpMHpMV1F5VFVpTTZkSkZDWT0iLCJzbG90cyI6eyJkZWZhdWx0Ijp7Im9mZnNldF90aW1lIjoiMjAxOC0wOC0yNyAxNDo0MzoxNC43NDIwMDArMDA6MDAifSwiZmlyc3RfdGltZV9saXN0ZXIiOnsib2Zmc2V0X3RpbWUiOiIyMDE4LTA4LTI3IDExOjM1OjI2LjQ1NTAwMCswMDowMCJ9fX0%3D

third page url=
https://*&session=eyJhZ2dyZWdhdGVfY291bnQiOjgwLCJzZXNzaW9uX2luaXRfYXQiOiIyMDE4LTA4LTI3VDE3OjA0OjU0LjY5ODMxNzg1NVoiLCJzaWduYXR1cmVfaGFzaCI6Iis1RGg4cEtWV3FpMHpMV1F5VFVpTTZkSkZDWT0iLCJzbG90cyI6eyJkZWZhdWx0Ijp7Im9mZnNldF90aW1lIjoiMjAxOC0wOC0yNyAxMzo1Mzo1MS4wMTEwMDArMDA6MDAifSwiZmlyc3RfdGltZV9saXN0ZXIiOnsib2Zmc2V0X3RpbWUiOiIyMDE4LTA4LTI3IDA5OjAyOjM5LjQyMzAwMCswMDowMCJ9fX0%3D

forth page url=
https://*&session=eyJhZ2dyZWdhdGVfY291bnQiOjEyMCwic2Vzc2lvbl9pbml0X2F0IjoiMjAxOC0wOC0yN1QxNzowNDo1NC42OTgzMTc4NTVaIiwic2lnbmF0dXJlX2hhc2giOiIrNURoOHBLVldxaTB6TFdReVRVaU02ZEpGQ1k9Iiwic2xvdHMiOnsiZGVmYXVsdCI6eyJvZmZzZXRfdGltZSI6IjIwMTgtMDgtMjcgMTI6MjI6MDAuNjEzMDAwKzAwOjAwIn0sImZpcnN0X3RpbWVfbGlzdGVyIjp7Im9mZnNldF90aW1lIjoiMjAxOC0wOC0yNyAwNzoyOToyOC4wOTEwMDArMDA6MDAifX19

---------------------------------------
The turn page and waiting time work as they should be when I put negative !loop
However, it does not work for my Eval statement to extract data at all... :idea:
do you have any idea to fix my eval statement?

Code: Select all

SET !VAR1 EVAL("var z=\"{{!LOOP}}\";z = (z % 40);if(z == 0){ z = 40};z=z++;")
'extract data
TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-i 
TAG POS={{!VAR1}} TYPE=dl ATTR=CLASS:* EXTRACT=htm
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('<dd>');y= x[1].split('</dd>'),z=y[0]; z;")
ADD Temp_Extract {{!VAR2}}
SET !EXTRACT {{!VAR2}}
TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-l EXTRACT=TXT
TAG POS={{!VAR1}} TYPE=TIME ATTR=CLASS:*-r<SP>*-w EXTRACT=TXT 
TAG POS={{!VAR1}} TYPE=A ATTR=CLASS:*-g<SP>media EXTRACT=HREF
Hum, OK for the Session ID in the URL, but again, if your Script works as an '.iim' looped from the Side-Panel, it will work the same if you handle the Looping from a '.js' Script...

If I have "any idea to fix your eval statement"...?, yep, of course, it's a simple Addition for 4 year old Kids in Primary School, ah-ah...! :wink:
If you want for example to loop your Script 100 times, you start with "-98", to which you add the same Nb to make it "0" (=> +98), and +1 to "get back to normal" like in your original Script with "!LOOP=1"... (Using your own Var instead of the raw '!LOOP' of course...)
- (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...
a2515125
Posts: 114
Joined: Tue Dec 06, 2016 3:37 am

Re: how to loop iim script automatically with windows schedu

Post by a2515125 » Tue Aug 28, 2018 3:25 am

what is wrong with my stupid code below
that seems only can extract POS = 40 Orzzz
i thought it could be like this .... :idea:
-999+1000=1
-998+1000=2
.
.
-1+1000=999

i am confused and stuck with Eval statement :((
something is wrong with my "Add" statement

Code: Select all

SET !REPLAYSPEED FAST
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 3
SET !TIMEOUT_STEP 0
SET !LOOP -999

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

TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-i 
TAG POS={{!VAR1}} TYPE=dl ATTR=CLASS:* EXTRACT=htm
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('<dd>');y= x[1].split('</dd>'),z=y[0]; z;")
ADD Temp_Extract {{!VAR2}}
SET !EXTRACT {{!VAR2}}
TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-l EXTRACT=TXT
TAG POS={{!VAR1}} TYPE=TIME ATTR=CLASS:*-r<SP>*-w EXTRACT=TXT 
TAG POS={{!VAR1}} TYPE=A ATTR=CLASS:*-g<SP>media EXTRACT=HREF 


then I try this code wont work either >"<

Code: Select all


SET !REPLAYSPEED FAST
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 3
SET !TIMEOUT_STEP 0
SET !LOOP -999

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

TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-i 
TAG POS={{!VAR1}} TYPE=dl ATTR=CLASS:* EXTRACT=htm
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('<dd>');y= x[1].split('</dd>'),z=y[0]; z;")
ADD Temp_Extract {{!VAR2}}
SET !EXTRACT {{!VAR2}}
TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-l EXTRACT=TXT
TAG POS={{!VAR1}} TYPE=TIME ATTR=CLASS:*-r<SP>*-w EXTRACT=TXT 
TAG POS={{!VAR1}} TYPE=A ATTR=CLASS:*-g<SP>media EXTRACT=HREF 

still failed to achieve ...Orzz

Code: Select all

SET !REPLAYSPEED FAST
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 3
SET !TIMEOUT_STEP 0
SET !LOOP -999

'extract url'
WAIT SECONDS=0.02
'set loop to scrape'
FILTER TYPE=IMAGES STATUS=ON

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


TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-i 
TAG POS={{!VAR1}} TYPE=dl ATTR=CLASS:* EXTRACT=htm
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('<dd>');y= x[1].split('</dd>'),z=y[0]; z;")
ADD Temp_Extract {{!VAR2}}
SET !EXTRACT {{!VAR2}}
TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-l EXTRACT=TXT
TAG POS={{!VAR1}} TYPE=TIME ATTR=CLASS:*-r<SP>*-w EXTRACT=TXT 
TAG POS={{!VAR1}} TYPE=A ATTR=CLASS:*-g<SP>media EXTRACT=HREF 

If I set my own var : SET !VAR_LOOP -999 , the script would only loop 1 time then stop
Also, that could not extract any data too ......>"<

Code: Select all

SET !REPLAYSPEED FAST
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 3
SET !TIMEOUT_STEP 0
SET !VAR_LOOP -999
ADD !VAR_LOOP 1000




'extract url'
WAIT SECONDS=0.02
'set loop to scrape'
FILTER TYPE=IMAGES STATUS=ON


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


TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-i 
TAG POS={{!VAR1}} TYPE=dl ATTR=CLASS:* EXTRACT=htm
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('<dd>');y= x[1].split('</dd>'),z=y[0]; z;")
ADD Temp_Extract {{!VAR2}}
SET !EXTRACT {{!VAR2}}
TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-l EXTRACT=TXT
TAG POS={{!VAR1}} TYPE=TIME ATTR=CLASS:*-r<SP>*-w EXTRACT=TXT 
TAG POS={{!VAR1}} TYPE=A ATTR=CLASS:*-g<SP>media EXTRACT=HREF 

chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: how to loop iim script automatically with windows schedu

Post by chivracq » Tue Aug 28, 2018 5:05 am

a2515125 wrote:what is wrong with my stupid code below
that seems only can extract POS = 40 Orzzz
i thought it could be like this .... :idea:
-999+1000=1
-998+1000=2
.
.
-1+1000=999

i am confused and stuck with Eval statement :((

Code: Select all

SET !REPLAYSPEED FAST
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 3
SET !TIMEOUT_STEP 0
SET !LOOP -999

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

TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-i 
TAG POS={{!VAR1}} TYPE=dl ATTR=CLASS:* EXTRACT=htm
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('<dd>');y= x[1].split('</dd>'),z=y[0]; z;")
ADD Temp_Extract {{!VAR2}}
SET !EXTRACT {{!VAR2}}
TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-l EXTRACT=TXT
TAG POS={{!VAR1}} TYPE=TIME ATTR=CLASS:*-r<SP>*-w EXTRACT=TXT 
TAG POS={{!VAR1}} TYPE=A ATTR=CLASS:*-g<SP>media EXTRACT=HREF 
then I try this code wont work either >"<

Code: Select all

SET !REPLAYSPEED FAST
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 3
SET !TIMEOUT_STEP 0
SET !LOOP -999

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

TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-i 
TAG POS={{!VAR1}} TYPE=dl ATTR=CLASS:* EXTRACT=htm
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('<dd>');y= x[1].split('</dd>'),z=y[0]; z;")
ADD Temp_Extract {{!VAR2}}
SET !EXTRACT {{!VAR2}}
TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-l EXTRACT=TXT
TAG POS={{!VAR1}} TYPE=TIME ATTR=CLASS:*-r<SP>*-w EXTRACT=TXT 
TAG POS={{!VAR1}} TYPE=A ATTR=CLASS:*-g<SP>media EXTRACT=HREF 
still failed to achieve ...Orzz

Code: Select all

SET !REPLAYSPEED FAST
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 3
SET !TIMEOUT_STEP 0
SET !LOOP -999

'extract url'
WAIT SECONDS=0.02
'set loop to scrape'
FILTER TYPE=IMAGES STATUS=ON

SET reload EVAL("var x; y='{{!LOOP}}'; url='https:*****%2Cdescending&collection_id=1243&cc_id=1645'; if(y==-999){x=url;} else{x='';}; x;")
URL GOTO={{reload}}

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

TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-i 
TAG POS={{!VAR1}} TYPE=dl ATTR=CLASS:* EXTRACT=htm
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('<dd>');y= x[1].split('</dd>'),z=y[0]; z;")
ADD Temp_Extract {{!VAR2}}
SET !EXTRACT {{!VAR2}}
TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-l EXTRACT=TXT
TAG POS={{!VAR1}} TYPE=TIME ATTR=CLASS:*-r<SP>*-w EXTRACT=TXT 
TAG POS={{!VAR1}} TYPE=A ATTR=CLASS:*-g<SP>media EXTRACT=HREF 
Your 1st Attempt looks a bit correct to me, to return [2-41], possibly the 'z' in the 1st 'y' is treated like a String, then you need to convert it to a Number...
The last Attempt comes a bit close as well, but you keep doing your "Operations" directly on the raw '!LOOP', I'm not sure about "ADD !LOOP" (if it passes Parsing Validation anyway...), but "SET !LOOP" is only read on the first Run, I told you twice already, you need to use your own Var...

And use 'PROMPT' to follow and debug your Vars... :idea:
But the Syntax you use in your 'EVAL()' with the 'Modulo[40]' is really not easy to debug as you keep reusing the same 'z' or 'y' several times... It's OK if you are "Advanced" and want to "impress" by compacting your JS..., the Syntax I use myself by "slowly" building 'x' => 'y' => 'z' is much more easy to follow, ... and to debug...! I told you you should harmonize all your 'EVAL()' Statements and adopt only one kind of Syntax that you really understand...
- (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...
a2515125
Posts: 114
Joined: Tue Dec 06, 2016 3:37 am

Re: how to loop iim script automatically with windows schedu

Post by a2515125 » Tue Aug 28, 2018 5:47 am

i prefer to use the 1st script that is much more simple to me to understand BUT really have no idea how to turn string "z" into number.
I would very appreciate if you can show me .........

I also try to use my own var but it seems I do not get it
if I dont set SET !LOOP -999 instead of SET !VARLOOP -999
the script would not loop..... :!:

PROMPT {{!VARLOOP}} shows undefined but I already give !VARLOOP 1000
it should debug it as 1000 for first prompt and as 1 for second prompt isn't it ?


Still this code below fails :(

Code: Select all

SET !REPLAYSPEED FAST
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 3
SET !TIMEOUT_STEP 0
SET !LOOP -999
SET !VARLOOP 1000

PROMPT {{!VARLOOP}}

ADD !VARLOOP {{!LOOP}}


PROMPT {{!VARLOOP}}



'extract url'
WAIT SECONDS=0.02
'set loop to scrape'
FILTER TYPE=IMAGES STATUS=ON




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


TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-i 
TAG POS={{!VAR1}} TYPE=dl ATTR=CLASS:* EXTRACT=htm
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('<dd>');y= x[1].split('</dd>'),z=y[0]; z;")
ADD Temp_Extract {{!VAR2}}
SET !EXTRACT {{!VAR2}}
TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-l EXTRACT=TXT
TAG POS={{!VAR1}} TYPE=TIME ATTR=CLASS:*-r<SP>*-w EXTRACT=TXT 
TAG POS={{!VAR1}} TYPE=A ATTR=CLASS:*-g<SP>media EXTRACT=HREF 


a2515125
Posts: 114
Joined: Tue Dec 06, 2016 3:37 am

Re: how to loop iim script automatically with windows schedu

Post by a2515125 » Tue Aug 28, 2018 6:28 am

i think i make it :)
Thank you!!

the code is below

Code: Select all

SET !REPLAYSPEED FAST
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 3
SET !TIMEOUT_STEP 0
SET !LOOP -999

SET !VAR1 EVAL("var z=\"{{!LOOP}}\"; var s = 1000 ; y = s+{{!LOOP}}  ; y = (y % 40);if(y == 0){ y = 40};y=y++;")

'prompt {{!VAR1}}





However, I still want to know how to use my own car and set add. My debug still catch undefined when using set my own var
a2515125
Posts: 114
Joined: Tue Dec 06, 2016 3:37 am

Re: how to loop iim script automatically with windows schedu

Post by a2515125 » Tue Aug 28, 2018 2:02 pm

i got another confused that three of my eval scripts are similar but the last one is not working why??
and what is different between var z={{!LOOP}} and "var z=\"{{!LOOP}}\"


this working

Code: Select all

SET !VAR1 EVAL("var z={{!LOOP}}; var s = 1000 ; y = s+z  ; y = (y % 40);if(y == 0){ y = 40};y=y++;")
this working

Code: Select all

SET !VAR1 EVAL("var z=\"{{!LOOP}}\"; var s = 1000 ; y = s+{{!LOOP}}  ; y = (y % 40);if(y == 0){ y = 40};y=y++;")
BUT this not working why?

Code: Select all

SET !VAR1 EVAL("var z=\"{{!LOOP}}\"; var s = 1000 ; y = s+z ; y = (y % 40);if(y == 0){ y = 40};y=y++;")
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: how to loop iim script automatically with windows schedu

Post by chivracq » Tue Aug 28, 2018 3:50 pm

a2515125 wrote:i prefer to use the 1st script that is much more simple to me to understand BUT really have no idea how to turn string "z" into number.
I would very appreciate if you can show me .........

I also try to use my own var but it seems I do not get it
if I dont set SET !LOOP -999 instead of SET !VARLOOP -999
the script would not loop..... :!:

PROMPT {{!VARLOOP}} shows undefined but I already give !VARLOOP 1000
it should debug it as 1000 for first prompt and as 1 for second prompt isn't it ?

Still this code below fails :(

Code: Select all

SET !REPLAYSPEED FAST
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 3
SET !TIMEOUT_STEP 0
SET !LOOP -999
SET !VARLOOP 1000

PROMPT {{!VARLOOP}}

ADD !VARLOOP {{!LOOP}}

PROMPT {{!VARLOOP}}

'extract url'
WAIT SECONDS=0.02
'set loop to scrape'
FILTER TYPE=IMAGES STATUS=ON

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

TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-i 
TAG POS={{!VAR1}} TYPE=dl ATTR=CLASS:* EXTRACT=htm
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('<dd>');y= x[1].split('</dd>'),z=y[0]; z;")
ADD Temp_Extract {{!VAR2}}
SET !EXTRACT {{!VAR2}}
TAG POS={{!VAR1}} TYPE=H4 ATTR=CLASS:*-l EXTRACT=TXT
TAG POS={{!VAR1}} TYPE=TIME ATTR=CLASS:*-r<SP>*-w EXTRACT=TXT 
TAG POS={{!VAR1}} TYPE=A ATTR=CLASS:*-g<SP>media EXTRACT=HREF
Oh...!, very good...!, you are "finally" using 'PROMPT' to follow and debug your Vars...! :D

Possible Explanation(s) why your Script is (still) not working is that I am not sure if you can use the '!' for User Defined Vars, this is "normally" reserved for Built-in Vars, the 'PROMPT' must give you the Answer anyway... And hum, even if it works, it's "Good Practice" to keep the '!' only for Built-in Vars anyway, your Script is then easier to "follow" for yourself and other Users that might get "confused", thinking... "Oh...!, I don't know this Command, maybe it's new in Version X..."

Your 'EVAL()' was working with the raw/Built-in '!LOOP' Var for which iMacros already "knew" for sure it's always a Number...! But when using User Defined Vars, iMacros doesn't "know" if your Var is "supposed to be" a Number or a String, I think for '!VARn' Vars it makes an Attempt to "detect" and threat the Content as Number or String, but => always String in case of "Doubt", and I wouldn't be surprised if User Defined Vars are always treated as a String, especially inside 'EVAL()'...
=> Then you would need to make sure that your 'z' is converted to a Number like I already mentioned several times... :roll:

Your "... BUT really have no idea how to turn string "z" into number." is a bit "useless", ah-ah...! :roll:
Simply start typing "convert str[ing to number javascript]" in Google and you already have the Answer(s)...! Not very complicated I would think...! :roll:
=> 'parseInt()' + 'parseFloat()' + 'Number()'...
Hum, even if I remember "trying" once the 'Number()' Method (on iMacros for FF, probably v8.8.2 and/or v8.9.7), as I never remember the Names of the 2 'parseXXX' Methods, ah-ah...!, and it didn't "really" work... But I didn't "insist"/investigate at that time, as I actually use a 4th Solution which is not mentioned but has always worked for me, and which consists of simply multiplying my Var/"String" by 1: [z*1] (without the Brackets), it works and it is shorter in 'EVAL()' than all JS Methods...
a2515125 wrote:i think i make it :)
Thank you!!

the code is below

Code: Select all

SET !REPLAYSPEED FAST
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 3
SET !TIMEOUT_STEP 0
SET !LOOP -999

SET !VAR1 EVAL("var z=\"{{!LOOP}}\"; var s = 1000 ; y = s+{{!LOOP}}  ; y = (y % 40);if(y == 0){ y = 40};y=y++;")

'prompt {{!VAR1}}
However, I still want to know how to use my own car and set add. My debug still catch undefined when using set my own var
Hum, OK, nice if it works, but you are a bit "lucky" I would think... The Syntax you are now using is a little bit "unreliable", I guess it works on '!LOOP' because of the Reasons I've mentioned above but it probably wouldn't work with any/some other kind of Vars..., at least last time I didn't some "Testing" on using (all kinds of) Vars in 'EVAL()', with Escaped Double-Quotes [\"], Single Quotes ['] or nothing [], but that was several years ago, probably around v8.40 for FF, I think...

More "reliable" in my "Experience" is to declare all Vars at the Beginning of the 'EVAL()' like I do with ["var s='{{!EXTRACT}}', n='{{!LOOP}}', u={{URL_My_Site}}; var x,y,z; ...] and reuse those s/n/u/etc Vars directly in the x/y/z "Building Statements" towards 'z' for the Final Result... This always works and you don't have to worry about (Escaped) Single/Double Quotes, except that you can take for granted that all Vars are probably treated like Strings and you can better convert the ones you need as Number to a Number, even if that is sometimes not needed...
a2515125 wrote:i got another confused that three of my eval scripts are similar but the last one is not working why??
and what is different between var z={{!LOOP}} and "var z=\"{{!LOOP}}\"

this working

Code: Select all

SET !VAR1 EVAL("var z={{!LOOP}}; var s = 1000 ; y = s+z  ; y = (y % 40);if(y == 0){ y = 40};y=y++;")
this working

Code: Select all

SET !VAR1 EVAL("var z=\"{{!LOOP}}\"; var s = 1000 ; y = s+{{!LOOP}}  ; y = (y % 40);if(y == 0){ y = 40};y=y++;")
BUT this not working why?

Code: Select all

SET !VAR1 EVAL("var z=\"{{!LOOP}}\"; var s = 1000 ; y = s+z ; y = (y % 40);if(y == 0){ y = 40};y=y++;")
Same "Story" about "converting a String to a Number", you are a bit "lucky" with the first two Statements, that it works with {{!LOOP}} without any Quotes and 'EVAL()' accepts it directly as a Number, but for the last one, your 'z' is seen as a String I think... (and if you didn't reuse 3x times the same 'y' for all Building Expressions, you could debug the whole 'EVAL()' part by part until you find which part is not "behaving" like you expect... Tja...!, I told you already, that Syntax you are using if for "Advanced" Users who either want to "show off" on a Forum after they've probably extensively tested that Syntax bit by bit, or for "really" Advanced Users who can dream in JS and have some "Built-in" JS Compiler in their Head and know for sure they don't make Mistakes... Good for you, good for them, I'm definitely not at that Level myself, ah-ah...! Hum..., and if you are, you should be answering all Threads on the Forum then, ah-ah...! (Hum, and you would know how to convert a String to a Nb, basic JS Functionality...)).

=> I "suspect" that your first 'y' would be returning "1000-999" as a String, instead of the "1" you expect..., which "screws" of course the next "("1000-999"%40)", the Modulo of a String is probably a bit "ugly", oops...! :shock:

>

:arrow: => This is how I would have built that 3rd 'EVAL()' of yours...: :idea:

Code: Select all

SET !VAR1 EVAL("var n='{{!LOOP}}'; var x,y,z; x=1000+(n*1); y=(x%40); if(y==0){z=41;} else{z=y+1;}; z;")
PROMPT VAR1:<SP>_{{!VAR1}}_
And if you need to change anything in the 'EVAL()', you can debug every single part in it by simply temporarily changing the Return from "z;" to "x;" then "y;"...

A bit "overkill", but that would give stg like:

Code: Select all

SET !VAR1 EVAL("var n='{{!LOOP}}'; var x,y,z; x=1000+(n*1); y=(x%40); if(y==0){z=41;} else{z=y+1;}; x;")
SET !VAR2 EVAL("var n='{{!LOOP}}'; var x,y,z; x=1000+(n*1); y=(x%40); if(y==0){z=41;} else{z=y+1;}; y;")
SET !VAR3 EVAL("var n='{{!LOOP}}'; var x,y,z; x=1000+(n*1); y=(x%40); if(y==0){z=41;} else{z=y+1;}; z;")
PROMPT DEBUG:<BR><BR>x:<SP>_{{!VAR1}}_<BR>y:<SP>_{{!VAR2}}_<BR>z:<SP>_{{!VAR3}}_
By simply changing one single Letter/Char in the 'EVAL()', you can follow and check exactly what each separate Expression in it is doing... 8)

You can try for example to remove the "*1" in "x=1000+(n*1);", maybe it is not needed, and "x=1000+n;" could work directly... :idea:
- (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...
a2515125
Posts: 114
Joined: Tue Dec 06, 2016 3:37 am

Re: how to loop iim script automatically with windows schedu

Post by a2515125 » Wed Aug 29, 2018 2:18 am

thank your detailed explanation so much!!!

I already try to remove "*1" in "x=1000+(n*1);"
and seems imacros detects it as string .......hehe
so by add "*1" would be simple and the easiest way to become Number
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: how to loop iim script automatically with windows schedu

Post by chivracq » Wed Aug 29, 2018 2:27 am

a2515125 wrote:thank your detailed explanation so much!!!

I already try to remove "*1" in "x=1000+(n*1);"
and seems imacros detects it as string .......hehe
so by add "*1" would be simple and the easiest way to become Number
As you see, exactly like I said..., and I didn't try/test anything... (And I don't have some JS Compiler in my Head..., rhoo...!, luckily...! :shock: )

But I hope you understand that when using "my" Syntax, you have FULL Control over your 'EVAL()' Statements... :idea:

And believe me, I'm very stupidly-low-level with JS, so I deliberately make "Things" very simple for myself, and if I can understand "Things" and if it works for me, then everybody should understand as well...! 8)
- (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...
Post Reply