session

Scraping Session

shouldStopScraping

boolean session.shouldStopScraping ( )

Description

Determine if the scrape has been stopped. This can be done using the stop button in the workbench or the stop scraping button on the web interface (for enterprise users).

Parameters

This method does not receive any parameters.

setMaxScriptsOnStack

void session.setMaxScriptsOnStack ( int maxScriptsOnStack ) (enterprise edition only)

Description

Get the total number of scripts that can be running concurrently. Default value for maxScriptsOnStack is 50.

getMaxScriptsOnStack

int session.getMaxScriptsOnStack ( )

Description

Get the total number of scripts allowed on the stack before the scraping session is forcibly stopped.

Parameters

This method does not receive any parameters.

Return Values

Returns max number of scripts that can be running at a time, as an integer.

getNumScriptsOnStack

int session.getNumScriptsOnStack ( )

Description

Get the number of scripts currently running.

Parameters

This method does not receive any parameters.

Return Values

Returns number of running scripts, as an integer.

setv

void session.setv ( String identifier, Object value )

Description

Set the value of a session variable (alias of setVariable).

getv

Object session.getv ( String identifier )

Description

Retrieve the value of a saved session variable (alias of getVariable).

Logging

Overview

Use of log is a great tool to ensure that your scrapes are working correctly as well as troubleshooting problems that arise. Though logging large amounts of information may slow down a scrape, the best way around this is not to remove log writing requests but rather change the verbosity of the logging when running the scrape in a production environment. If you do this, know that you make it harder to troubleshoot some problems should they arise.

The number of methods provided is merely to enhance your ability to log information according to importance.

Web Interface Interactions

Overview

These methods are used in connection with the web interface of screen-scraper. Their use will provide the interface with more detailed information regarding the state of a running scrape. If you are not running the scrapes using the web interface then these methods are not particularly helpful to you.

As the web interface is an enterprise edition feature, these methods are only available in enterprise edition users.

setCharacterSet

void session.setCharacterSet ( String characterSet )

Description

Set the general character set used in page response renderings. This can be particularly helpful when the pages render characters incorrectly.

getMemoryUsage

int sutil.getMemoryUsage ( ) (enterprise edition only)

Description

Get memory usage of screen-scraper.

Parameters

This method does not receive any parameters.

Return Values

Returns the average percentage of memory used by screen-scraper over the past 30 seconds, as an integer.