Reading a URL w/ VB.NET

  • Thread starter Thread starter Leeper
  • Start date Start date
L

Leeper

Does anyone know how to read in a URL and pull information out. I
wanting to read in a URL and pull out information to store in a
database. Any help would be appreciated.

Thanks
Leeper
 
* (e-mail address removed) (Leeper) scripsit:
Does anyone know how to read in a URL and pull information out. I
wanting to read in a URL and pull out information to store in a
database. Any help would be appreciated.

\\\
Imports System.IO
Imports System.Net
..
..
..
Dim wrq As WebRequest = _
WebRequest.Create("http://stud3.tuwien.ac.at/~e0025861/index.html")
Dim wrp As WebResponse = wrq.GetResponse()
Dim sr As StreamReader = New StreamReader(wrp.GetResponseStream())
MessageBox.Show(sr.ReadToEnd())
///
 
Leeper,
In addition to the WebRequest sample Herfried showed, you can use the
System.Net.WebClient. Note WebClient internally uses the WebRequest, hiding
a lot of the implementation details...

\\\
Imports System.IO
Imports System.Net
..
..
..
Dim client As New WebClient()
Dim stream as Stream =
client.OpenRead("http://stud3.tuwien.ac.at/~e0025861/index.html")
Dim reader = New StreamReader(stream)
MessageBox.Show(reader.ReadToEnd())
///

I normally use the WebRequest object as you have significant more control,
however the WebClient is useful in that it handles a lot of details for you!

Hope this helps
Jay
 
Back
Top