Liu Kang
Liu Kang

Reputation: 1389

iMacros: URL GOTO = null, skip?

I have a long sequence of code, that visit a website, logins in, posts content from a .csv and saves information, logs out and visit the next website. It's all hard-coded.

What is the easiest way of skipping parts of the code? I have 60 websites. Example:

Right now, I don't want the macro visiting website 5, 6, 7, 9, 10, 22, 26, 35, 40, 45, 50, 59.
In one hour, I don't want the macro visiting website 4, 5 , 9, 10, 19, 30, 31, 49 and 50.

Example how my code looks:

' First Website 
TAB T=1
SET !DATASOURCE test.csv
SET !DATASOURCE_COLUMNS 2
SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 2

URL GOTO=http://liu.com

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:mortalSubmit ATTR=NAME:title CONTENT={{!COL1}}
TAG POS=1 TYPE=TEXTAREA FORM=ID:mortalSubmit ATTR=ID:post CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:mortalSubmit ATTR=ID:submit

ADD !EXTRACT {{!URLCURRENT}}
ADD !EXTRACT {{!COL1}}
ADD !EXTRACT {{!COL2}}
TAG POS=1 TYPE=DIV ATTR=CLASS:success EXTRACT=TXT
TAG POS=1 TYPE=DIV ATTR=CLASS:error EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=report.csv

TAG POS=2 TYPE=A ATTR=TXT:Log<SP>out

WAIT SECONDS=3

' Second Website 

TAB T=1
SET !DATASOURCE test.csv
SET !DATASOURCE_COLUMNS 2
SET !LOOP 3
SET !DATASOURCE_LINE {{!LOOP}}
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 2

URL GOTO=http://kang.com/admin

TAG POS=1 TYPE=A ATTR=TXT:Add<SP>New
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:combatSubmit ATTR=NAME:title CONTENT={{!COL1}}
TAG POS=1 TYPE=TEXTAREA FORM=ID:combatSubmit ATTR=ID:post CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:combatSubmit ATTR=ID:submit

ADD !EXTRACT {{!URLCURRENT}}
ADD !EXTRACT {{!COL1}}
ADD !EXTRACT {{!COL2}}
TAG POS=1 TYPE=DIV ATTR=CLASS:updated EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=report.csv

TAG POS=2 TYPE=A ATTR=TXT:Exit

WAIT SECONDS=3

This works perfectly for me.

So, in the example above how do I make the code skip First Website and straight go for the Second Website? I know I can make the first parts of the code a comment and change SET !LOOP from 3 to 2. It works, but I can't do this with 60 websites.

I was thinking..

I have a seperate .csv with URL information:

URL,Name
http://liu.com,LIU.COM
http://kang/admin.com,KANG.COM

And in the code:

SET !DATASOURCE urls.csv

' First Website
SET !LOOP 2
URL GOTO={{!COL1}}

' Second Website
SET !LOOP 3
URL GOTO={{!COL1}}

And somehow make IF col1 = null GOTO COMMAND LINE x, or something! Or just let type in dasjdkaskasdasasdasg.com in col1 and let it run trough, though this would be a timewaster. Does it exist a better solution?

SET !LOOP is also a problem. Is it possible to make the first !SETLOOP 2 and every other that comes next !SETLOOP previous+1

Best regards,

Liu Kang

UPPDATED: Impossible to achive this just by using IIM. Tried long with EVAL to make SETLOOP go up, but this is very limited. See updated comment.

Summary from comment:

Upvotes: 2

Views: 4681

Answers (1)

Bestmacros
Bestmacros

Reputation: 1867

here is code example on

how to import .csv data to Javascript when jQuery is not allowed with iMacros?

var checksubj,scrape;
checksubj =  "CODE:";
checksubj +=  "SET !DATASOURCE example.csv" + "\n"; 
checksubj +=  "SET !DATASOURCE_COLUMNS 1" + "\n"; 
checksubj +=  "SET !DATASOURCE_LINE {{line}}" + "\n";
checksubj +=  "SET !extract {{!col1}}" + "\n";
iimSet("line",1);
iimPlay(checksubj);
scrape=iimGetLastExtract(0);

Upvotes: 1

Related Questions