Re: parsing:retrieving data from websites

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 
displaying
messages to a user while on a website. You can write your own function, I will 
send
you the code, you can do whatever you usually do when handling messages to a 
client
from in an ASP or html page etc... It is just a method of displaying a message 
in
a stateless environment you can handle any error as you choose. Logger is 
another
of my oldest classes which  writes messages, just strings,  to a text file for 
later
use in debugging or whatever I need the info for. Anyway, here is the old code, 
she
has been a good old girl. I would rewrite it - could make it shorter but too 
lazy
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 Vb.net 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
Try
'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
Finally
if Not IsNothing(objSR) then
objSR.Close()
End If
If Not IsNothing(objWResp) then
objWResp.Close()
End If
End Try
Return Ret
End Function
' <ApplicationInclude>
Const FatelError As String = "FatelError"
Dim Ret As String = ""
' </ApplicationInclude>
End Class

Other related posts: