Imacros Extraction Using Two Loops

Hi My requirement is I have to read one csv file which contains 100 urls and for each url I have to scrape the data. Each url webpage contains 100 lines of data suppose which I am extracting on changing the POS value .So my question is how do I maintain two loops using VB script and macro. Please help... If I am witing two loops the inner loop should break if no data i.e if #EANF# is found

3

1 Answer


I'm not sure what data you're trying to extract, but this script will get your foot in the door..

1 VERSION BUILD 7020226 RECORDER=CR
2 SET !DATASOURCE inputURLs.csv
3 SET !DATASOURCE COLUMNS 1
4 SET !LOOP 2
5 SET !DATASOURCE_LINE {{!LOOP}}
6 SET !EXTRACT_TEST_POPUP NO

7 URL GOTO={{!COL1}}
8 TAG POS=1 TYPE=SPAN ATTR=CLASS:EXAMPLE EXTRACT=TXT
9 SAVEAS TYPE=EXTRACT FOLDER:C:\Output FILE=output.csv

This script uses a filename called "inputURLs.csv" located in your default Datasources folder, begins looping on row 2 (assuming you have a header row), extracts the text a certain tag contains for each URL that's inputted and extracts the results to a file called "output.csv" located a folder called "Output" on your C: Drive. You'll need to replace line 8 with the page elements that you want to extract.

This can be built right into the IDE, no VB scripting required.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest