'Imacros script extract and save to csv
I'm new to imacros and am having a little trouble figuring out this script. Here is my imacros script
VERSION BUILD=8920312 RECORDER=FX
TAB T=1
SET !DATASOURCE input.csv
SET !DATASOURCE_COLUMNS 1
SET !DATASOURCE_LINE {{!LOOP}}
URL GOTO=https://URL.com/Property/Search
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/Property/Search ATTR=ID:PropertyAddress CONTENT={{!COL1}}
TAG POS=1 TYPE=BUTTON FORM=ACTION:/Property/Search ATTR=ID:btnSearchSubmit
WAIT SECONDS=10
TAG POS=1 TYPE=TD ATTR=TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\admin\Documents\iMacros\Downloads FILE=extract.csv`
The input.csv has a list of addresses. That part works fine.
The part I'm having trouble with is extracting text. Here is the code from the page with the text I want to extract:
<td colspan="5" class="style2">
TEXT TO EXTRACT
</td>
I have the extract.csv in the downloads folder so I don't think that's an issue. The script seems to run fine except for it's not extracting the text. The text extraction popup is just blank.
I'm also having trouble determining the best way to save the extracted the data. All of the data in the input.csv is addresses and they're all in column 1. Some of them will not return any results when submitted.
Ideally, when saving the extracted data I'd like to save both the address pulled from the {{!COL1}} variable and the extracted data to the same row in the extract.csv spread sheet with the address and extracted data being in separate columns.
Hope I explained that well enough. Thanks in advance for any pointers!
Solution 1:[1]
The second part of your question can be solved simply by adding one line after WAIT SECONDS=10 :
SET !EXTRACT {{!COL1}} .
The issue as to extraction seems to lie in a wrong TYPE=TD (or just in absence of any text, if ‘iMacros’ doesn’t return the ‘#EANF#’ value). Try to record again a click on the element you want to extract text from and compare the obtained command with your TAG POS=1 TYPE=TD ATTR=TXT:* EXTRACT=TXT .
Anyway you might test for example:
TAG POS=1 TYPE=TD ATTR=COLSPAN:5&&CLASS:style2 EXTRACT=TXT .
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
