As you mentioned, you do need to save the dataset first in a session variable, which can be done by checking the box next to "Automatically save the data set generated..." The name that will be used by the scraping session is the one given the data set in the "Identifier" field.
Next, here is an old ASP example. Make sure to make the appropriate changes to reflect the identifiers used in your scraping session.
<html>
<head><title>Slashdot screen-scraper results</title></head>
<body>
<%
' Create the object.
Set objRemoteSession = Server.CreateObject("Screenscraper.RemoteScrapingSession")
' Set up the remote session.
Call objRemoteSession.Initialize("Slashdot")
' Check for errors.
If objRemoteSession.IsError Then
Response.Write( "Error: " & objRemoteSession.GetErrorMessage )
Else
%>
Scraping data...
<%
Response.Flush
' Tell screen-scraper to scrape the data.
Call objRemoteSession.Scrape
%>
data scraped.<br>
Outputting results...
<%
Response.Flush
' Write out the results.
' Retrieve and store the saved data set.
objRemoteSession.StoreVariable("DATASET")
%>
<table border="1" cellpadding="5" align="center">
<tr>
<th>Story Title</th>
<th>Topic</th>
<th>Posted By</th>
<th>Posted Date</th>
<th>Department</th>
<th>Story</th>
</tr>
<%
' Walk through the results.
For i = 0 To objRemoteSession.GetNumDataRecordsForDataSet( "DATASET" ) - 1
%>
<tr>
<%
' The story title may contain a white link, so we make it blue instead.
Response.Write( "<td>" & Replace( objRemoteSession.GetDataSetValue( "DATASET", i, "STORY_TITLE" ), "FFFFFF", "336699" ) & "</td>" )
Response.Write( "<td>" & objRemoteSession.GetDataSetValue( "DATASET", i, "TOPIC" ) & "</td>" )
Response.Write( "<td>" & objRemoteSession.GetDataSetValue( "DATASET", i, "POSTED_BY_NAME" ) & "</td>" )
Response.Write( "<td>" & objRemoteSession.GetDataSetValue( "DATASET", i, "POSTED_DATE" ) & "</td>" )
Response.Write( "<td>" & objRemoteSession.GetDataSetValue( "DATASET", i, "DEPARTMENT" ) & "</td>" )
Response.Write( "<td>" & objRemoteSession.GetDataSetValue( "DATASET", i, "STORY" ) & "</td>" )
Response.Flush
%>
</tr>
<%
Next
%>
</table>
<%
End If
' Disconnect from the server.
Call objRemoteSession.Disconnect
%>
</body>
</html>
While I understand you do not want to provide the live examples anymore, what do you provide as an alternative? I am having trouble with data sets when calling from an external ASP script and I cannot find anything in the current documentation to help. As I understood from the examples last time, when you call from external, when calling for a Data Set scrape, you still need an internal script to identify and set the data set array which I no longer know how to do without the examples. Any ideas? Thanks. :roll:
That is a valid question. We no longer bundle those examples with screen-scraper. We found that we looked bad when one of those other sites changed. Instead, our tutorials include examples of scraping sites which we do have control over the content. Those are the current examples.
I am sorry for any inconvenience this may have caused. If you have any further feedback on this issue please let us know what you think.
Can't find the weather & slashdot examples
the tutorials are great, but more examples would help. can't you just create some examples on the screen-scrapper.com site that we could scrape?
great product, just needs better documentation and examples for simple people like me :?
Can't find the weather & slashdot examples
gdixon,
As you mentioned, you do need to save the dataset first in a session variable, which can be done by checking the box next to "Automatically save the data set generated..." The name that will be used by the scraping session is the one given the data set in the "Identifier" field.
Next, here is an old ASP example. Make sure to make the appropriate changes to reflect the identifiers used in your scraping session.
<head><title>Slashdot screen-scraper results</title></head>
<body>
<%
' Create the object.
Set objRemoteSession = Server.CreateObject("Screenscraper.RemoteScrapingSession")
' Set up the remote session.
Call objRemoteSession.Initialize("Slashdot")
' Check for errors.
If objRemoteSession.IsError Then
Response.Write( "Error: " & objRemoteSession.GetErrorMessage )
Else
%>
Scraping data...
<%
Response.Flush
' Tell screen-scraper to scrape the data.
Call objRemoteSession.Scrape
%>
data scraped.<br>
Outputting results...
<%
Response.Flush
' Write out the results.
' Retrieve and store the saved data set.
objRemoteSession.StoreVariable("DATASET")
%>
<table border="1" cellpadding="5" align="center">
<tr>
<th>Story Title</th>
<th>Topic</th>
<th>Posted By</th>
<th>Posted Date</th>
<th>Department</th>
<th>Story</th>
</tr>
<%
' Walk through the results.
For i = 0 To objRemoteSession.GetNumDataRecordsForDataSet( "DATASET" ) - 1
%>
<tr>
<%
' The story title may contain a white link, so we make it blue instead.
Response.Write( "<td>" & Replace( objRemoteSession.GetDataSetValue( "DATASET", i, "STORY_TITLE" ), "FFFFFF", "336699" ) & "</td>" )
Response.Write( "<td>" & objRemoteSession.GetDataSetValue( "DATASET", i, "TOPIC" ) & "</td>" )
Response.Write( "<td>" & objRemoteSession.GetDataSetValue( "DATASET", i, "POSTED_BY_NAME" ) & "</td>" )
Response.Write( "<td>" & objRemoteSession.GetDataSetValue( "DATASET", i, "POSTED_DATE" ) & "</td>" )
Response.Write( "<td>" & objRemoteSession.GetDataSetValue( "DATASET", i, "DEPARTMENT" ) & "</td>" )
Response.Write( "<td>" & objRemoteSession.GetDataSetValue( "DATASET", i, "STORY" ) & "</td>" )
Response.Flush
%>
</tr>
<%
Next
%>
</table>
<%
End If
' Disconnect from the server.
Call objRemoteSession.Disconnect
%>
</body>
</html>
Brent
screen-scraper.com
Where to Find the Examples
While I understand you do not want to provide the live examples anymore, what do you provide as an alternative? I am having trouble with data sets when calling from an external ASP script and I cannot find anything in the current documentation to help. As I understood from the examples last time, when you call from external, when calling for a Data Set scrape, you still need an internal script to identify and set the data set array which I no longer know how to do without the examples. Any ideas? Thanks. :roll:
Can't find the weather & slashdot examples
OK Thanks :)
Can't find the weather & slashdot examples
edisonc,
That is a valid question. We no longer bundle those examples with screen-scraper. We found that we looked bad when one of those other sites changed. Instead, our tutorials include examples of scraping sites which we do have control over the content. Those are the current examples.
I am sorry for any inconvenience this may have caused. If you have any further feedback on this issue please let us know what you think.
Brent
screen-scraper.com