API

API Documentation

Overview

When writing scripts within screen-scraper, there are a number of objects and methods available to you. The Using Scripts page provides an overview of working with scripts, where this page provides details on specific objects and methods you'll use when scripting within screen-scraper.

The examples given here assume you're using "Interpreted Java" as the scripting language, but there should be very little difference in syntax if you decide to use another language. For example, if you're scripting in VBScript, you would simply omit the semi-colon at the end of each line, and for methods that don't return a value you would precede them with the VBScript keyword "Call" (either that, or omit the parentheses around the method parameters).

Built-in objects

screen-scraper provides four built-in objects, which will be available in scripts depending on when they're run. These objects are: session, scrapeableFile, dataSet, and dataRecord. See the "Variable scope" section on the Using Scripts page for details on which objects are available based on when scripts are run. For example, if you're running a script associated with an extractor pattern "After pattern is applied", you won't have access to the "dataRecord" object, but you will have access to the "dataSet" object.

The various built-in objects are detailed below:

* session: This variable refers to the currently running scraping session.
* scrapeableFile: This refers to the scrapeable file that is currently being requested and analyzed.
* dataSet: A data set is analogous to a result or record set that would be returned from a database query. A data set contains any number of data records, which are analogous to rows in a database. The dataSet object holds all data records extracted by an extractor pattern after it has been applied as many times as possible to the HTML retrieved by a scrapeable file.
* dataRecord: This gives access to the most recently extracted data record. This will most likely only be used in scripts that get accessed after each time an extractor pattern is applied. This object simply extends Hashtable, and documentation on its methods can be found here. Note that this object is populated using the names of tokens from extractor patterns. So, for example, if your extractor pattern uses a token named "CITY_CODE" the data extracted by that extractor pattern would be retrieved like so: cityCode = dataRecord.get( "CITY_CODE" );.
* com.screenscraper.scraper.RunnableScrapingSession: This is a class that can be instantiated within a script in order to run a scraping session. The "Maximum number of concurrent running scraping sessions" in the "Settings" dialog box will control how many scraping sessions can be run simultaneously.
* com.screenscraper.xml.XmlWriter: Oftentimes you want to write extracted data directly to an XML file. This class facilitates doing that.

API documentation

Use the quick links here to jump to more extended details of each of the methods below: