Re: parsing:retrieving data from websites

  • From: "Ricks Place" <OFBGMail@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 14 Jan 2009 09:17:49 -0500

Hi Tyler: I sent this but it did not appear back in my in-box. If you, I, don't 
see it I will follow up with something like an attachment just in case e-mail 
is blockiing the code.
Here is the raw class I just pulled from an older project.
UserMsg.Show is another of my Class functions that act like a MessageBox for 
messages to a user while on a website. You can write your own function, I will 
you the code, you can do whatever you usually do when handling messages to a 
from in an ASP or html page etc... It is just a method of displaying a message 
a stateless environment you can handle any error as you choose. Logger is 
of my oldest classes which  writes messages, just strings,  to a text file for 
use in debugging or whatever I need the info for. Anyway, here is the old code, 
has been a good old girl. I would rewrite it - could make it shorter but too 
to fix something that's not broken.
If you want the UserMsg and Logger Classes just post and I will paste them. They
are in but were originally CSharp as was most of my early works.
Public Class WebDownloader
Public  Function RequestWebData(ByVal pstrURL As String) As String
Dim objWReq As System.Net.WebRequest = Nothing
Dim objWResp As System.Net.WebResponse = Nothing
Dim objSR As System.IO.StreamReader = Nothing
'Contact the website
objWReq = System.Net.HttpWebRequest.Create(pstrURL)
objWResp = objWReq.GetResponse()
'Read the answer from the Web site and store it into a stream
objSR = New System.IO.StreamReader(objWResp.GetResponseStream)
Ret = objSR.ReadToEnd
Catch Ex As Exception
UserMsg.Show( "Catch Triggered in WebDownloader, RequestData:")
UserMsg.Show( Ex.ToString())
Logger.WriteLine( "WebDownloader, RequestData:Catch Triggered")
Logger.WriteLine( Ex.ToString())
Ret = FatelError
if Not IsNothing(objSR) then
End If
If Not IsNothing(objWResp) then
End If
End Try
Return Ret
End Function
' <ApplicationInclude>
Const FatelError As String = "FatelError"
Dim Ret As String = ""
' </ApplicationInclude>
End Class

Other related posts: