Trouble accessing Scraped info in DataSet via ASP.NET

Hello!

I am having a difficult time accessing the data scrapped into a dataset (multiple records). I have no trouble retrieving the single session variables and the Log shows my DataSet is being populated.

I am using ASP.NET (Web Matrix; fairly new to ASP.NET) and cannot seem to get the class structure right. Could you provide a generic sample of retrieving info from a Screen Scraper DataSet via ASP.NET (including DIM)?

Thank you!

-Les

Trouble accessing Scraped info in DataSet via ASP.NET

For anyone else having similar problems, below is some sample code that worked for me (using MS VB.NET 2005 Express Beta). I gave up on using the COM components and am using the .NET components.

Dim remoteSession As Screenscraper.RemoteScrapingSession
remoteSession = New Screenscraper.RemoteScrapingSession("SESSIONNAME")
remoteSession.Scrape()

Dim DS As Screenscraper.DataSet = New Screenscraper.DataSet

DS = remoteSession.GetVariable("DATASET_NAME")
Dim cnt As Integer = DS.NumDataRecords
If cnt > 0 Then
Dim bDex As Integer
Dim FIELD_ONE As Integer
Dim FIELD_TWO As String
For bDex = 0 To cnt - 1
FIELD_ONE = DS.Item(bDex, ("NUMERIC_SCRAPED_FIELD"))
FIELD_TWO = DS.Item(bDex, ("TEXT_SCRAPED_FIELD"))
' ... do whatever with them ...
Next
End If

-Les

Trouble accessing Scraped info in DataSet via ASP.NET

Les,

The following is the old example no longer included with the code. Make sure to change the scraping session and variable names to match your own work.

/**
 * An example of using remote scraping sessions.
 *
 * @author    Brent Wenerstrom
 */

using System;
using System.Collections;
using Screenscraper;

public class DataSetRemoteScrapingSessionExample
{
        /**
         * The entry point.
         */
        public static void Main( string[] args )
        {
                try
                {
                        // Create a remoteSession to communicate with the server.
                        RemoteScrapingSession remoteSession = new RemoteScrapingSession( "Slashdot" );

                        // Scraper.
                        remoteSession.Scrape();

                        // Get the data.
                        // If the returned value is null an exception will be thrown later.
                        DataSet dataSet = ( DataSet )remoteSession.GetVariable( "DATASET" );

                        // Temporarily holds data records.
                        DataRecord tmpDataRecord = null;

                        Console.WriteLine( "============================================================================" );

                        // Iterate through the data records.

                        for( IEnumerator iterator = dataSet.AllDataRecords.GetEnumerator(); iterator.MoveNext(); ) {
                                {
                                        tmpDataRecord = ( DataRecord )iterator.Current;

                                        // Enumerate through the data record, outputting each of the fields.
                                        for( IDictionaryEnumerator en = tmpDataRecord.GetEnumerator(); en.MoveNext(); )
                                        {
                                                Console.WriteLine( en.Key + "=" + en.Value );
                                        }
                                        Console.WriteLine( "============================================================================" );
                                }

                        }
                        // Very important! Be sure to disconnect from the server.
                        remoteSession.Disconnect();
                }
                catch( Exception e )
                {
                        Console.WriteLine( e );
                }
        }
}

Brent
screen-scraper.com

Trouble accessing Scraped info in DataSet via ASP.NET

Actually, just a snippet of some of the CODE that probably existed in the old example
(See the file examples/dotNET/DataSetRemoteScrapingSessionExample.cs for an example on accessing a data set from a RemoteScrapingSession.)

...would probably be sufficent. At least it would help me a bit in trying to access the info in the DataSet via VB.NET (I gave up on ASP.NET due to a different limitation not related to Screen-Scraper)

-Les

Trouble accessing Scraped info in DataSet via ASP.NET

Les,

I am sorry to say that at the current time we do not have an ASP.NET example. We do have documentation on .NET with a C# twist located here. We plan on eventually including an ASP.NET example on our website as time permits.

Brent
screen-scraper.com

Exactly where is the C# (or VB.NET) sample?

I clicked "here" on the above comment and it took me to the screen-scraper HOME page. Could you tell me where exactly the .NET sample you refer to is located?

Gary, A few things have

Gary,

A few things have changed 2004 and I'm not sure where that original example file is. However, we have up-to-date examples and documentation here.

Documentation:
http://community.screen-scraper.com/invoking_screen-scraper_via_NET

Tutorial (w/ example):
http://community.screen-scraper.com/Tutorial_4_page_3_Invoking%20screen-scraper%20from%20C%2523.NET

Let us know if you have any questions.

-Scott