Repeated Crashing of workbench...bug?

The following interpreted java script causes repeated crashing of workbench, leaving Java.exe running and thus the 'cant bind to port, db' error. I have to go into task manager and quit java.exe. Is this a bug?
If I comment out the getVariable line, and replace with a String file = "foo.csv", then it works fine. Any ideas? How should I be fetching a session variable if not like this?

Thanks!!

-----------------------------------------------------------------------
// Generate a new "Scrape Details" scraping session.
runnableScrapingSession = new com.screenscraper.scraper.RunnableScrapingSession( "WB_ScrapeSession" );

//file name for output
runnableScrapingSession.setVariable( "FILE", "warnerbrosrecords.csv" );

// Prepare our CSV headers
FileWriter out = null;

try
{
// Open up the file to be appended to.
String file = runnableScrapingSession.getVariable( "FILE" );
//String file = "warnerbrosrecords.csv";
out = new FileWriter( file, true );

//write the headers to the file
out.write( "Title,Length,Posted,Views,URL,Tags\n" );

// Close up the file.
out.close();
}
catch( Exception e )
{
exit();
}

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

Repeated Crashing of workbench...bug?

Hi,

You can retrieve the value once the scraping session is running. Realize that you're dealing with two completely different objects. In the script you're referring to, you're using a RunnableScrapingSession, whereas scripts that get invoked while a scraping session is running use a ScrapingSession object. The bug you discovered disallows getting the value of a variable from a RunnableScrapingSession (though it is now fixed), but you've always been able to get variables from a ScrapingSession object.

Just to clarify a bit further, if you create a script that gets invoked from within a scraping session (e.g., "After file is scraped", "After each pattern application") you would do something like this:

session.getVariable( "MY_VAR" );

In that case, you'd be using the ScrapingSession object and not the RunnableScrapingSession object.

Hopefully that clarifies. Feel free to post a reply if we can provide further detail.

Kind regards,

Todd

thanks and a question

Hi Todd,

Thankyou for the offer, will keep it in mind!

I am curious though it looks like I can not call session.setVariable() untill after I run runnableScrapingSession.scrape(). Is this true? If so, how do I pass a value from the starting script to a script called in the middle of a scrape?

I know how to set a variable
runnableScrapingSession.setVariable( "FILE", "warnerbrosrecords.csv" );
but not how to retrieve it fom within the java script.

thanks!

-Keith

Repeated Crashing of workbench...bug?

Hi Keith,

Looks like this was, indeed, a result of a bug in screen-scraper. To be honest, I'm not entirely sure why it crashes the entire application. Nonetheless, we've applied a fix, which seems to have resolved it. The fix will be included in our next alpha release. You can subscribe to our blog ([url]http://blog.screen-scraper.com/[/url]) if you'd like to be notified when that becomes available.

Our policy is to offer a discount on a Pro Edition license to anyone that discovers a bug of which we were previously unaware. This one's a bit of a special case in that you were calling an undocumented method (RunnableScrapingSession.getVariable), but, notwithstanding, I'd still be happy to offer you a discount, should you need another license. If you'd like to take advantage of this, you can email me directly. My email address is my first name at screen-scraper.com.

Kind regards,

Todd