initialize( "Shopping Site", "192.168.0.5", 8778 );
$session->initialize( "Shopping Site", "localhost", 8730 );
// Set the variables.
// Remember that these two top variables correspond to the POST
// parameters we use for the "Login" scrapeable file.
$session->setVariable( "EMAIL_ADDRESS", "test@test.com" );
$session->setVariable( "PASSWORD", "testing" );
// This parameter is the search term the user designated.
$session->setVariable( "SEARCH", $search_term );
// We start screen-scraper at page 1 of the search results.
// Note that we could have also done this in an "initialize"
// script within screen-scraper, which is common.
$session->setVariable( "PAGE", "1" );
// Tell the session to scrape. This method call might take
// a little while since it will need to wait for screen-scraper
// to fully extract the data before it returns.
$session->scrape();
// Check for errors.
if( $session->isError() )
{
echo "An error occurred: " . $session->getErrorMessage() . "
";
exit();
}
// We increase the size of the buffer in case we get a lot
// of data back.
$session->setBufferSize( 64000 );
// Get the data set that was stored by screen-scraper in a
// session variable. This data set corresponds to the "PRODUCTS"
// extractor pattern found under the "Details page" scrapeable
// file.
$data_set = $session->getVariable( "PRODUCTS" );
// We check to see if we got any records back by looking for
// a title in the first data record in the set.
if( $data_set[0]["TITLE"]==null )
{
// Output a message if we didn't find any results.
?>
Sorry, no results were found for .
Title |
Price |
Model |
Shipping Weight |
Manufactured By |
|
|
|
|
|
disconnect();
}
?>