[Resolved] Simple Question.. Reading from a web page...
Ok, I'm quite sure this is a lot easier than it sounds, but can anyone point me at how to read information from an outside web page? I.e., check http://www.somestupidwebpage.com for the words "Updated Available", then read the update number after it, or such? Or, even just check the properties from a web page, to see the date of the last update.
I'm 1/2 way worried this requires building my own baby browser; when I last played with VB (VB 5), it looked that way.. Any easy way to do it now?
Thanks!
Re: Simple Question.. Reading from a web page...
Well here's a little code you can use to read in the contents of the URL into one string, then it would be a matter of parsing the data (or searching the text) for those particular words, or the data you need...
VB Code:
'Code in your sub...
Dim returnstring As String
returnstring = SearchPage("http://www.yahoo.com")
'Function Code...
Private Function SearchPage(ByVal sURL As String) As String
Dim client As System.Net.WebClient = New System.Net.WebClient()
Dim data As System.IO.Stream = client.OpenRead(sURL)
Dim reader As System.IO.StreamReader = New System.IO.StreamReader(data)
SearchPage = reader.ReadToEnd
End Function
That works fine and dandy if your connection is up and the site is found, might need to add some extra code to handle the cases where there is no connection found or no site found at that address...
Re: Simple Question.. Reading from a web page...