Reputation: 746
I have a iMacro that logs in, performs a search and extracts the "results" to a text file. My challenge is that I am only getting the first page of the "results". I would like to extract all of the "results" from each page. Sometimes there is only one page of results, other times there may be 10 pages of results.
The "Results" page 1 is formatted like this (two spaces before each hyperlink): Results Page 1 2 3
The "Results" page 2 is formatted like this: Results Page 1 2 3
The "Results" page 3 is formatted like this: Results Page 1 2 3
Not knowing how many pages the search will return, how can I only extract the third page when there is a page 3?
Here is a portion of the Macro:
TAG POS=1 TYPE=INPUT:IMAGE FORM=NAME:form1 ATTR=ID:SEARCH
'=> Extract data of 2nd table (POS=2) on **page 1 **
TAG POS=1 TYPE=A ATTR=TXT:1
TAG POS=2 TYPE=TABLE ATTR=TXT:*location* EXTRACT=TXT
'The SAVEAS statement was added manually to write the extracted table to a file
SAVEAS TYPE=txt FOLDER=* FILE=mytable_{{!NOW:yymmdd_hhnnss}}
'=> Extract data from 2nd table (POS=2) on **page 2**
TAG POS=1 TYPE=A ATTR=TXT:2
TAG POS=2 TYPE=TABLE ATTR=TXT:*location* EXTRACT=TXT
SAVEAS TYPE=txt FOLDER=* FILE=mytable_{{!NOW:yymmdd_hhnnss}}
'=> Extract data from 2nd table (POS=2) on **page 3**
TAG POS=1 TYPE=A ATTR=TXT:3
TAG POS=2 TYPE=TABLE ATTR=TXT:*location* EXTRACT=TXT
SAVEAS TYPE=txt FOLDER=* FILE=mytable_{{!NOW:yymmdd_hhnnss}}
Upvotes: 1
Views: 682
Reputation: 1867
You can simply run your script with loop parameter where you state number of pages to scrape, all you need is to modify it a little bit like this:
TAG POS=1 TYPE=A ATTR=TXT:{{!loop}}
TAG POS=2 TYPE=TABLE ATTR=TXT:*location* EXTRACT=TXT
SAVEAS TYPE=txt FOLDER=* FILE=mytable_{{!NOW:yymmdd_hhnnss}}
Upvotes: 1