RunnableScrapingSession

RunnableScrapingSession RunnableScrapingSession ( String name ) (professional and enterprise editions only)
RunnableScrapingSession RunnableScrapingSession ( String name, ScrapingSession inheritedScrapingSession ) (professional and enterprise editions only)
RunnableScrapingSession RunnableScrapingSession ( String name, ScrapingSession inheritedScrapingSession, boolean inheritHttpState ) (professional and enterprise editions only)

Description

Initiates a RunnableScrapingSession object using the name of an existing scraping session.

Parameters

  • name The name of the scraping session to be run, as a string.
  • inheritedScrapingSession (optional) Scraping session whose session variables should be copied to the new scraping session. If it is left off no session variables will be passed to the new scrape.
  • inheritHttpState (optional) Whether HTTP state information, like cookies, should be inherited. This can be important if you have logged into a site and want the runnable scraping sessions to also be logged in.

Return Values

Returns a RunnableScrapingSession. On failure an error will be thrown.

Change Log

Version Description
5.0 inheritHttpState added as optional parameter.
4.5 Available for professional and enterprise editions.

Class Location

com.screenscraper.scraper

Examples

Creating RunnableScrapingSession

 // Creates a new runnable session for the scraping session "My Session".
 myScrapingSession = new com.screenscraper.scraper.RunnableScrapingSession( "My Session" );

 // Creates a new runnable session for the scraping session "My Session"
 // and passes it the current scraping session from which it will inherit
 // session variables and logging.
 myScrapingSession = new com.screenscraper.scraper.RunnableScrapingSession( "My Session", session );

Catching Error

 // If you renamed a scrape and are worried about someone not having the new one
 // you can use the thrown error to identify a problem that can be solved using
 // the older name
 try {
     // Attempt to create scrape using the new name
     myScrapingSession = new com.screenscraper.scraper.RunnableScrapingSession( "My Session - New" );
 } catch ( error ) {
     session.logWarn( error.toString() );
     session.logWarn( "Attemping to start scrape with old name." );
     myScrapingSession = new com.screenscraper.scraper.RunnableScrapingSession( "My Session" );
 }