Scripting in Interpreted Java

Overview

screen-scraper uses the BeanShell library to allow for scripting in Java. If you've done some programming in C or JavaScript you'll probably find BeanShell's syntax familiar. Documentation for BeanShell is excellent, and we'd recommend referring to it as you program.

Interpreted Java is just a phrase used to mean that it is java that does not require being compiled.

See the using scripts and API pages for details on objects and methods that you can make use of in a script. We also use Interpreted Java in all of our tutorials, which should get you familiar with how it's used in screen-scraper.

It is possible to access Java libraries in screen-scraper. See adding Java libraries for more details.

Example

// This particular example will only work with professional and enterprise editions of screen-scraper
// RunnableScrapingSession is reserved for these editions

// Import the RunnableScrapingSession class.
import com.screenscraper.scraper.*;

// Generate a new "Weather" scraping session.
runnableScrapingSession = RunnableScrapingSession( "Weather" )

// Put the zip code in a session variable so we can reference it later.
runnableScrapingSession.setVariable( "ZIP_CODE", "90001" )

// Tell the scraping session to scrape.
runnableScrapingSession.scrape()

Java Tutorials

We use Java in the screen-scraper tutorials but if you would like to learn more about Java you can look for tutorials online. The following are some good Java resources: