Extract with relative Positioning
Top  Previous  Next

Related example macro: Demo-ExtractRelative

When extracting data from a complex websites, the extraction can be made easier if you can tell iMacros to start the search for the extraction anchor after a specific point on the page (as opposed to start from the top, which is the default).

E.g., assume you want to extract data from a specific cell in a table, in this case the size of the land in the second table.

Result page 1
Result page 2

result1


result2

Without relative positioning you would have to count the cell from the top of the page, including cell from other tables that come before the land table. Although the extraction wizard can do this for you, you run into problems as soon as the number of rows in a table are not constant as they are in the above example. The Transfer table of result 1 has four, that of result 2 has five row. Thus, an absolute position parameter like so

EXTRACT POS=8 TYPE=TXT ATTR=<TD>*   

will potentially result in the extraction of an unwanted result.

With relative positioning you tell iMacros to search for the extraction anchor located after the position that is indicated by a
TAG command right before your EXTRACT command. In our case we click on the table title "Land" before starting the extraction wizard to create a TAG command. Note that this TAG command does not click on any link, rather it only marks an element to indicate a position for the following EXTRACT command. Relative positions are indicated with an R before the position number.

TAG POS=1 TYPE=B ATTR=TXT:Land
EXTRACT POS=R
1 TYPE=TXT ATTR=<TD>*







Page URL http://www.iopus.com/imacros/help/extract_relative.htm