session and RunnableScrapingSession objects

Hello,

I have a script (written inJava) starting like this:

// Creates a new runnable session for the scraping session "ABC".
runnableScrapingSession = new com.screenscraper.scraper.RunnableScrapingSession( "ABC" );

// Start the scraping session.
runnableScrapingSession.scrape();

session.scrapeFile( "req 2" );

However I get the following error:

[quote]Error Message:

Attempt to invoke method: scrapeFile() on undefined variable or class name: session : at Line: 8.[/quote]

From reading the docs I get the understanding that:

com.screenscraper.scraper.RunnableScrapingSession is a session object that gets initialized with a particular scraping session that is built in Screen Scraper's GUI. It is used to start a particular scraping session from a script.

The session object holds the current running scraping session.

So based on this understanding, in the above script I am starting an "ABC" scraping session and then, using the session object (which should refer to the ABC scraping session), I am scraping the "req 2" scrapeable file (which belongs to the ABC scraping session).

...but its not working! :x So what am I not getting here? Thanks in advance

session and RunnableScrapingSession objects

speedster,

You may be pleased to learn that RunnableScrapingSession is being deprecated in later versions of screen-scraper. If you update your version of the professional edition you'll find that you no longer need a separate script containing calls to RunnableScrapingSession to run scraping sessions from an outside batch or shell script. Instead, you simply call the name of the scraping session and screen-scraper handles the starting of the scraping session.

For example,

java -Xmx256M -jar screen-scraper.jar -s "My Scraping Session" > log\my-scraping-session.log

The number "256" represent the amount of memory in MB allocated to screen-scraper for the running of the given session. You're also able to specify a path to the log file for this this particular session. This is the same log you would see if you were running it from the workbench.

More good things to come.

-Scott

session and RunnableScrapingSession objects

Thanks for the reply Scott.

That makes it all clear now. :) I was trying to do everything from one script, including starting and controlling the whole flow of the scraping session, but I guess Screen Scraper does not let you do that.

So I will break the work down into mulitple smaller scripts and call them using the GUI based on a particular event.

Thanks again.

session and RunnableScrapingSession objects

speedster,

It's not a bad assumption but it's not exactly how things work. When a scraping session is called from within a script via RunnableScrapingSession the session does not actually start at that point. You're only able to access the session object starting from scraping session itself (in your case the scraping session "ABC") and any subsequent scripts or scrapeable files.

"...com.screenscraper.scraper.RunnableScrapingSession is a session object that gets initialized with a particular scraping session"

The operative word here being "with". In your case you were trying to access it "before".

For a matrix of when variables are accessible or "in scope" please see the following.

http://www.screen-scraper.com/support/docs/using_scripts.php#variable_scope

If your call your script via a batch or shell script you would just need to move any references to the session object to a script that is being called from your "ABC" scraping session (or thereafter).

Please let us know if you have any other questions about this.

Thanks,
Scott