How to step 2 with iMacros loop? How to select every other href?

Pentium10 picture Pentium10 · Apr 12, 2011 · Viewed 19.8k times · Source

I have this iMacros code fragment

VERSION BUILD=7200328 RECORDER=FX
TAB T=1
URL GOTO=http://feedburner.google.com/fb/a/myfeeds
SET !LOOP 1
TAG POS={{!LOOP}} TYPE=A ATTR=HREF:http://feedburner.google.com/fb/a/dashboard?id=*
TAG POS=1 TYPE=A ATTR=TXT:Publicize
TAG POS=1 TYPE=SPAN ATTR=TXT:Socialize
TAG POS=1 TYPE=SELECT FORM=NAME:editFeedActionForm ATTR=ID:postFields CONTENT=$Title<SP>and<SP>Body
WAIT SECONDS=2
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:mainForm ATTR=VALUE:Save
TAG POS=1 TYPE=A ATTR=TXT:FeedBurner

The above script will extract hrefs that match the http://feedburner.google.com/fb/a/dashboard?id=* rule, and will try to navigate further on the page.

However there are two links on the page with the same stuff and I want to loop only odd values. Like 1,3,5,7 how to set a custom step value for loop?

Answer

mflips picture mflips · Aug 18, 2011

Such simple arithmetic can also be done in the iMacros language:

'Store the value of !loop in a variable
SET !VAR1 {{!LOOP}}
ADD !VAR1 {{!LOOP}}
'now !var1 = 2*!loop. Subtract 1 to get odd numbers.
ADD !VAR1 -1
TAG POS={{!VAR1}} TYPE=A ATTR=HREF:http://feedburner.google.com/fb/a/dashboard?id=*

Regards,

Marcia