2

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:

  • Splitted up the code into one .iim-file per website
  • All .iim-files have a unique SETLOOP and imports data from the same .CSV
  • A Javascript file execute each .iim-file
  • Working on a solution to make the Javascript execute the .iim-files only when COL3 in the .CSV contains data, problem now is to make the Javascript import data from the .CSV when jQuery isn't allowed when using iMacros.
Community
  • 1
  • 1
Liu Kang
  • 1,359
  • 4
  • 22
  • 45
  • Just wondering... are you mayhaps building some sort of automated spambot? – STT LCU Jul 08 '13 at 06:39
  • I am indeed creating a "bot" that posts to websites, but I is _not_ spam. Please look my previous question http://stackoverflow.com/questions/17478645/posts-to-wordpress-sites-via-dropbox-fetch-and-reporting-the-urls The content that is posted is _unique_ for every website. I pay as much as 15$ for every article. I am doing this manually today and I have a trusted accounts on all of the websites with many, many, many posts. I am posting from the same accounts every time, if I would be spamming I would not use the same. I just want a bot that makes my job exactly as I do it today, but faster. – Liu Kang Jul 08 '13 at 06:47
  • 1
    Then your job is commendable. My hat's off to you. :) – STT LCU Jul 08 '13 at 07:29
  • 1
    you can't do this is regular IIM - convert your code to js format and run different website code according to IF statement result – Bestmacros Jul 08 '13 at 09:08
  • Bestmacros: Can't this be done with EVAL? – Liu Kang Jul 08 '13 at 09:45
  • 1
    @Bestmacros Thanks for pointing me to the right direction. Working on a .JS script now, I have splitted up the code so every website has it's own .iim-file. Every .iim file imports data from a single .CSV I now have to make the .JS script only run a .iim-file if the .CSV contatins data on a special line. The first problem is, how do I import .csv data to Javascript when jQuery is not allowed with iMacros? – Liu Kang Jul 10 '13 at 13:58
  • you're welcome. attaching code sample as answer – Bestmacros Jul 10 '13 at 17:02

1 Answers1

1

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);
Bestmacros
  • 1,697
  • 12
  • 26
  • Thanks for your help. Solved it here: http://stackoverflow.com/questions/17551713/import-csv-data-into-javascript-and-run-execute-if-string-contains-data – Liu Kang Jul 12 '13 at 13:11