![]() |
Using Scraping Sessions |
Overview
A scraping session is simply a way to collect together files that you want scraped. Typically you'll create a scraping session for each site you want to scrape informaiton from.
You can create a new scraping session by clicking the New Scraping Session button (looks like a gear) or by selecting "File->New Scraping Session" from the menu.
General tab

The "General" tab allows you to manage basic actions and information related to the scraping session.
Delete: Deletes the scraping session.
Scripts tab

Using this tab scripts can be designated to run either before or after the scraping session runs. This can be useful for functions like initializing session variables and performing clean-up after the session is finished. The script to be run is designated under the "Script Name" column. The sequence the scripts should be invoked in is determined by the "Sequence" column. Indicate the event that should trigger the script using the "When to Run" column. If the checkbox in the "Enabled?" column is not checked the script will not get run.
Log tab

The "Log" tab displays messages as the scraping session is running. This is one of the most valuable tools in working with and debugging scraping sessions. As you're creating your scraping session you'll want to run it frequently and check the log to ensure that it's doing what you expect it to.
Advanced tab

This tab contains a number of settings that may be required when working with certain sites.
Anonymization tab

See the Anonymization page of the documentation for details on this pane.
Running Scraping Sessions Within Scraping Sessions (enterprise edition only)
It is also possible to run a scraping session within a scraping session that is already running via the RunnableScrapingSession class. Detailed documentation on methods available for the RunnableScrapingSession class are in our API documentation. Here's a specific example of how the RunnableScrapingSession might be used in a screen-scraper script:
// Generate a new RunnableScrapingSession object that will inherit
// from the current scraping session. This object will be used
// to run the scraping session "My Scraping Session"
myRunnableScrapingSession = new com.screenscraper.scraper.RunnableScrapingSession( "My Session", session );
// Because we passed the "session" object to the RunnableScrapingSession
// it will have access to all of the session variables within the
// currently running session. As such, there's no need to explicitly
// set any new session variables. We simply tell it to scrape.
myRunnableScrapingSession.scrape();
// Once it's done scraping, because it inherited from our currently
// running scraping session, we have access to any session variables
// that were set when the RunnableScrapingSession ran in the context
// of our currently running scraping session. For example, let's
// suppose that when the RunnableScrapingSession ran it set a new
// variable called "MY_VAR". Because of the inheritance, we could
// do something like this to see th new value:
session.log( "MY_VAR: " + session.getVariable( "MY_VAR" ) );From here:
On scripts: