How to loop through links on page using iMacros

Neno picture Neno · Mar 2, 2012 · Viewed 10.5k times · Source

I would like to use iMacros for the following task:

  1. on specific page navigate to each link ending with /id=* (how to do a loop ?!)
  2. save the HTML body content of those id's pages to file
  3. on each of those pages there is 'further details button' save the HTML content of popup window (details)

In the meantime, I figured out how to do it and there is a code which works as planed:

VERSION BUILD=7401110 RECORDER=FX
TAB T=1
URL GOTO=http://bla/bla/Documents.xxx
SET !LOOP 1
TAG POS={{!LOOP}} TYPE=A ATTR=HREF:http://bla/bla?id=*
TAG POS=1 TYPE=BODY ATTR=* EXTRACT=HTM
TAG POS=1 TYPE=SPAN ATTR=TXT:View<SP>details
TAG POS=1 TYPE=BODY ATTR=* EXTRACT=HTM
TAB T=2
TAG POS=1 TYPE=BODY ATTR=* EXTRACT=HTM
SAVEAS TYPE=EXTRACT FOLDER=D:\iMacrosExports\ FILE=Extract_{{!NOW:ddmmyy_hhnnss}}.txt
WAIT SECONDS=2

How to include actual value of id=* in the name of saved file?

SET !EXTRACT_TEST_POPUP NO
TAB T=1
URL GOTO=http://bla
SET !LOOP 1
TAG POS={{!LOOP}} TYPE=A ATTR=HREF:http://bla?id=*
SET !VAR1 {{!URLCURRENT}}
TAG POS=1 TYPE=SPAN ATTR=TXT:View<SP>details
WAIT SECONDS=4
TAB T=2
TAG POS=1 TYPE=BODY ATTR=* EXTRACT=HTM
SAVEAS TYPE=EXTRACT FOLDER=D:\iMacrosExport\ FILE=Extract_{{!VAR1}}.txt
WAIT SECONDS=2

Answer