Using Session Variables
Overview
Session variables allow you store values that will persist across the life of a scraping session.
Setting session variables
There are a few different ways to set session variables.
- Within a script using the setVariable method of the session object
- Designate that the value matched by a extractor token should be saved in a session variable (check Save in session variable in the main tab of the extractor token).
- Using the RemoteScrapingSession object from external sources (such as a PHP or ASP script) via their setVariable methods (see scripting in screen-scraper for more details).
Retrieving values from session variables
As with setting session variables, there is more than one way to retrieve values of session variables.
- Within a script using the getVariable method of the session object.
- Embed the identifier for the session variable, surrounded by ~# and #~ delimiters.
If you have a session variable identified by QUERY_PARAM you might embed it into the URL field of a scrapeable file using http://www.mydomain.com/myscript.php?query=~#QUERY_PARAM#~. screen-scraper will automatically replace the ~#QUERY_PARAM#~ with the value of the session variable.
scraper on 07/16/2010 at 4:27 pm
- Printer-friendly version
- Login or register to post comments