using System; using System.Collections.Generic; using System.Text; using Screenscraper; namespace Shop { class Shopping { static void Main(string[] args) { // Generate a RemoteScrapingSession object, which // acts as the driver, or interface, to screen-scraper. // If you're running screen-scraper on a different computer // than the one the C# file resides on you'll want to // modify and use the top version instead of the bottom one. //RemoteScrapingSession remoteScrapingSession = new RemoteScrapingSession("Shopping Site", "192.168.0.5", 8778 ); RemoteScrapingSession remoteScrapingSession = new RemoteScrapingSession("Shopping Site"); // Set the variables. // Remember that these two top variables correspond to the POST // parameters we use for the "Login" scrapeable file. remoteScrapingSession.SetVariable("EMAIL_ADDRESS", "test@test.com"); remoteScrapingSession.SetVariable("PASSWORD", "testing"); // screen-scraper will use this parameter to search the products. remoteScrapingSession.SetVariable("SEARCH", "dvd"); // 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. remoteScrapingSession.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. remoteScrapingSession.Scrape(); // 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. DataSet products = (DataSet)remoteScrapingSession.GetVariable("PRODUCTS"); // Iterate through each of the data records screen-scraper // extracted, outputting each of them. for (int i = 0; i < products.NumDataRecords; i++) { DataRecord product = products[i]; Console.WriteLine("======================================="); Console.WriteLine("Product #" + i); Console.WriteLine("Title: " + product["TITLE"]); Console.WriteLine("Model: " + product["MODEL"]); Console.WriteLine("Shipping Weight: " + product["SHIPPING_WEIGHT"]); Console.WriteLine("Manufactured By: " + product["MANUFACTURED_BY"]); Console.WriteLine("======================================="); } // Be sure to disconnect from the server. remoteScrapingSession.Disconnect(); } } }