Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

551
Views
How to run two loops by iMacros?

I'm on Firefox 55.0.2 (64-bit), iMacros 9.0.3, Windows10 x64.

I'm trying to get all HREFs from all website pages and fail on two loops.

However, the looping works, but after every founded link, the URL is reloaded. This is my iMacro code:

VERSION BUILD=9030808 RECORDER=FX
SET !ERRORIGNORE YES
TAB T=1

SET !DATASOURCE links.csv 
SET !DATASOURCE_COLUMNS 1
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
URL GOTO={{!COL1}}
WAIT SECONDS=15

TAG XPATH="(//body//a)[{{!LOOP}}]" EXTRACT=HREF

ADD !EXTRACT {{!URLCURRENT}}

SAVEAS TYPE=EXTRACT FOLDER=* FILE=links.csv

Then I tried it another way, with this code related to this answer https://stackoverflow.com/a/18435002/1992004.

var macro;
macro =  "CODE:";
macro +=  "VERSION BUILD=9030808" + "\n"; 
macro +=  "TAB T=1" + "\n"; 
macro +=  "SET !ERRORIGNORE YES" + "\n"; 
macro +=  "SET !EXTRACT_TEST_POPUP NO" + "\n"; 
macro +=  "SET !DATASOURCE links.csv" + "\n";
macro +=  "SET !DATASOURCE_COLUMNS 1 " + "\n";
macro +=  "SET !LOOP 1" + "\n"; 
macro +=  "SET !DATASOURCE_LINE {{i}}" + "\n"; 
macro +=  "URL GOTO={{!COL1}} " + "\n"; 
macro +=  "WAIT SECONDS=15" + "\n"; 

var macro1;
macro1 =  "CODE:";
macro1 +=  "TAG POS={{n}} TYPE=A ATTR=HREF:* EXTRACT=HREF" + "\n"; 
macro1 +=  "SAVEAS TYPE=EXTRACT FOLDER=* FILE=links.csv" + "\n"; 

for (var i=1;i<20;i++)
{
iimSet("i",i)
iimPlay(macro)

var n=1;

while(true)
{
iimSet("n",n)

var ret=iimPlay(macro1);

if(ret<0)
{
break;
}

n++;
}

}

I saved the last code as .iim and .js:

  • In the case of .iim I get an error MacroSyntaxError: unknown command: VAR, line 1 (Error code: -910).
  • In the case of .js, I get the error The LOOP button can only be used with macro (".iim") files. In a Javascript (".js") file, you can use Javascript itself for loops..

What would be the correct code to get both loops to work?

@Shugar @macroscripts @chivracq do you probably have a hint for me?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!