1

I'm trying to build a data scraper with iMacros to first search for a category in a zip code on yelp and then go through each profile on each page and scrape certain information and save it to a csv file with line breaks between each profile. When the macro reaches the end as in last profile on last page for that search it goes back and searches same thing in new zip code over and over until its done with my zip code list. my problem is i cant figure out how to make it loop from the extraction part rather then the whole thing and how to make it go to the next zip code when its done and start all over until the while zip code file is finished. I am using a paid version 9.00.2379 of iMacros.

Here is what I have so far and i appreciate greatly any help..

SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
TAB T=1
URL GOTO=http://www.yelp.com/
TAG POS={{!loop}} TYPE=TD FORM=ID:form1 ATTR=TXT:*
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/search ATTR=NAME:find_desc CONTENT=italian<SP>restaurant
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/search ATTR=NAME:find_loc CONTENT=11234
TAG POS=1 TYPE=BUTTON:SUBMIT FORM=ACTION:/search ATTR=ID:header-search-submit
TAG POS=1 TYPE=H3 ATTR=CLASS:search-result-title EXTRACT=TXT
TAG POS=1 TYPE=DIV ATTR=CLASS:secondary-attributes EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=S:\imacro-extract FILE=Extract-test1.csv
TAG POS=2 TYPE=H3 ATTR=CLASS:search-result-title EXTRACT=TXT
TAG POS=2 TYPE=DIV ATTR=CLASS:secondary-attributes EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=S:\imacro-extract FILE=Extract-test1.csv
TAG POS=3 TYPE=H3 ATTR=CLASS:search-result-title EXTRACT=TXT
TAG POS=3 TYPE=DIV ATTR=CLASS:secondary-attributes EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=S:\imacro-extract FILE=Extract-test1.csv
TAG POS=4 TYPE=H3 ATTR=CLASS:search-result-title EXTRACT=TXT
TAG POS=4 TYPE=DIV ATTR=CLASS:secondary-attributes EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=S:\imacro-extract FILE=Extract-test1.csv
TAG POS=5 TYPE=H3 ATTR=CLASS:search-result-title EXTRACT=TXT
TAG POS=5 TYPE=DIV ATTR=CLASS:secondary-attributes EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=S:\imacro-extract FILE=Extract-test1.csv
TAG POS=6 TYPE=H3 ATTR=CLASS:search-result-title EXTRACT=TXT
TAG POS=6 TYPE=DIV ATTR=CLASS:secondary-attributes EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=S:\imacro-extract FILE=Extract-test1.csv
TAG POS=7 TYPE=H3 ATTR=CLASS:search-result-title EXTRACT=TXT
TAG POS=7 TYPE=DIV ATTR=CLASS:secondary-attributes EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=S:\imacro-extract FILE=Extract-test1.csv
TAG POS=8 TYPE=H3 ATTR=CLASS:search-result-title EXTRACT=TXT
TAG POS=8 TYPE=DIV ATTR=CLASS:secondary-attributes EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=S:\imacro-extract FILE=Extract-test1.csv
TAG POS=9 TYPE=H3 ATTR=CLASS:search-result-title EXTRACT=TXT
TAG POS=9 TYPE=DIV ATTR=CLASS:secondary-attributes EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=S:\imacro-extract FILE=Extract-test1.csv
TAG POS=10 TYPE=H3 ATTR=CLASS:search-result-title EXTRACT=TXT
TAG POS=10 TYPE=DIV ATTR=CLASS:secondary-attributes EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=S:\imacro-extract FILE=Extract-test1.csv
WAIT SECONDS=60
TAG POS=1 TYPE=A ATTR=TXT:→

What i need to figure out now is how to pull categories & zip codes from a csv file, run each search until its full done with each profile and each page available and keep looping until every zip code is done for every category

Note: this version will only scrape information from the actual list page rather then the profile itself, the next version will be actually going into each profile and scraping rather then just scraping off the list of search results.

again i thank gratefully anyone who can help this noob get his macro working :)

4

0 回答 0