Elementary session problem

This is basic - the Hello World tutorial writes a 0 bytes file and throwns
a BSF info: null at line: 0 column: columnNo error.

Looks like the session is out of scope.

The following is a variant which tries to catch the error.
---------------------------------------------------------------

Starting scraper.
Running scraping session: Hello World
Processing scripts before scraping session begins.
Scraping file: "File from Hello World"
File from Hello World: Processing scripts before a file is scraped.
File from Hello World: URL is: http://www.screen-scraper.com/tutorial/basic_form.php?text_string=xy.
File from Hello World: Scraping file with URL: http://www.screen-scraper.com/tutorial/basic_form.php?text_string=xy
File from Hello World: Sending request.
File from Hello World: Processing scripts before all pattern applications.
File from Hello World: Extracting data for pattern "null"
File from Hello World: The following data elements were found:
null--DataRecord 0:
MYVAR=xy
File from Hello World: Processing scripts after a pattern application.
File from Hello World: Processing scripts after all pattern applications.
Processing script: "Helloout"
Writing data to a file.
File from Hello World: An error occurred while processing the script: Helloout
File from Hello World: The error message was: BeanShell script error: Sourced file:

try
{
session.log( "Writing data to a file." );

// Open up the file to be appended to.
out = new FileWriter( "test.txt", true );

// Write out the data to the file.
out.write( dataRecord.get( "MYVAR" ) + "\t" );
out.write( "\n" );

// Close up the file.
out.close();
}
catch( Exception e )
{
session.log( "An error occurred while writing the data to a file: " + e.getMessage() );
}; > : Attempt to invoke method: get() on undefined variable or class name: dataRecord : at Line: 3 : in file:

try
{
session.log( "Writing data to a file." );

// Open up the file to be appended to.
out = new FileWriter( "test.txt", true );

// Write out the data to the file.
out.write( dataRecord.get( "MYVAR" ) + "\t" );
out.write( "\n" );

// Close up the file.
out.close();
}
catch( Exception e )
{
session.log( "An error occurred while writing the data to a file: " + e.getMessage() );
}; > : try { BSF info: null at line: 0 column: columnNo
File from Hello World: Processing scripts after a file is scraped.
Processing scripts after scraping session has ended.
Scraping session finished.

Elementary session problem

Anonymous Proxy ? What's that ? In most cases, general purposes proxy servers ( from proxy list ) do inform the target server about the address of the computer that made the request, transmitting the IP-address and other personal information to the website. But among different kinds of proxy servers ( from proxy list ) there are so called anonymous proxy servers ( from proxy list ) that can hide your IP address, which is a unique ID assigned to identify your location, as well as many other personal information, thereby saving you from vulnerabilities related to it.: http://www.socksproxylist.com

Elementary session problem

Thanks, Donal, that's excellent feedback. We're actually in the process of revising our tutorials, so we'll include your suggestion as part of that.

Kind regards,

Todd Wilson
[email protected]

Elementary session problem

Hi,

These lines from your log reveal the issue

File from Hello World Processing scripts after a pattern application.
File from Hello World Processing scripts after all pattern applications.
Processing script "Helloout"

The error you're seeing is happening because you're invoking your "Helloout" script after all pattern applications as opposed to invoking it after each pattern application. If you invoke the script after all pattern applications the "dataRecord" variable is no longer in scope. This page from our documentation might be helpful

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

Take a look at the section entitled "Variable scope".

By the way, this is a relatively common mistake, so any feedback on how we might be able to clarify this would be much appreciated.

Many thanks,

Todd Wilson
[email protected]