Resume Scrape at Specified Point
The following script is useful in cases where you would like to restart a scrape from a specific point. It will generally be called from your "Search Results" page. This may come in handy if for some reason your scrape stops or breaks. Rather than starting your scrape over from the beginning, you may use this script to start scraping the "Details" page only after a value has been reached. This script may also be useful when you wish to skip to a point in the search results before proceeding onto the "Details" page. This script is an example of a scrape that stopped on Georgia, while scraping information from all 50 states. With this script in place, details will be scraped for every state after(and including) Georgia.
// You may wish to declare it in the initializing script at the beginning of the scrape.
// This if statement will set the "START" variable to the string "1"
// when your scrape has reached the appropriate "STATE" to beginning scraping
if (session.getVariable("STATE").equals("GEORGIA")){
session.setVariable("START", "1");
}
// Once the if statement above has evaluated to "true", the if statement below
// will also evaluate to "true" each time this script is called, and the "My Scrape--3 details"
// page will be called.
if (session.getVariable("START").equals("1")){
session.scrapeFile("My Scrape--3 details");
}
Note: If you are writing to a .csv file (say, using one of the "Write to File" scripts here in the script repository) the new values will be concatenated to the file.
- Printer-friendly version
- Login or register to post comments