Simple iMacros Loop and Extract
I'm very new to the world of iMacro scripting, and as such I am having difficulty getting (what I believe to be) a very simply data scrape working.
The site I wish to scrape consists of an index page (a table with each new row being a hyperlink to a product page), and then product pages (same format every time). I'd like the macro to do the following....
- Clicking first hyperlink (table row ie.
POS1
) - Once page loaded, scrape 10 fields (will always be in the same place on each page)
- Go
BACK
(to index page) - Increment down to the next hyperlink (the next table row ie.
POS2
) - Extract data and repeat
- Export the data as a single file/csv with each set of scraped data being a new line/row
This is what I have so far... (link removed because it requires a login)
VERSION BUILD=7401598
TAB T=1
TAB CLOSEALLOTHERS
URL GOTO=https://XXXXXXXXXXXX
TAG POS={{!loop}} TYPE=TD FORM=ID:form1 ATTR=TXT:*
TAG POS=8 TYPE=TD FORM=ID:form1 ATTR=TXT:* EXTRACT=TXT
TAG POS=6 TYPE=TD FORM=ID:form1 ATTR=TXT:* EXTRACT=TXT
TAG POS=20 TYPE=TD FORM=ID:form1 ATTR=TXT:* EXTRACT=TXT
TAG POS=24 TYPE=TD FORM=ID:form1 ATTR=TXT:* EXTRACT=TXT
TAG POS=22 TYPE=TD FORM=ID:form1 ATTR=TXT:* EXTRACT=TXT
TAG POS=34 TYPE=TD FORM=ID:form1 ATTR=TXT:* EXTRACT=TXT
TAG POS=38 TYPE=TD FORM=ID:form1 ATTR=TXT:* EXTRACT=TXT
TAG POS=42 TYPE=TD FORM=ID:form1 ATTR=TXT:* EXTRACT=TXT
TAG POS=46 TYPE=TD FORM=ID:form1 ATTR=TXT:* EXTRACT=TXT
TAG POS=66 TYPE=TD FORM=ID:form1 ATTR=CLASS:labelBold EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=C:\iMacrosExports\ FILE=Extract_{{!NOW:ddmmyy_hhnnss}}.csv
WAIT SECONDS=2
BACK
The script above is only collecting data from the first pro开发者_如何学JAVAduct page, and exporting it as multiple CSV's (however many times I declare it to loop).
Any help would be GREATLY appreciated. If you require more info, please let me know.
Your macro looks alright. I would only remove the BACK command at the end, since you have the URL GOTO which navigates back to the index page at each loop. As long as you are using the "Play (Loop)" button, it should work...
Does the macro work if you increment the value of POS manually? I mean, you run first a macro with POS=1 (instead of {{!loop}}, then again with POS=2, and so on.
If you have problems you can also write directly to support@iopus.com or post your question in the iMacros forum.
Regards,
Marcia
精彩评论