Reading a http page

  • Thread starter Thread starter Ali.M
  • Start date Start date
A

Ali.M

Hi,

What is the shortest way to read contents of an http page into an string?

Thanks,
Alan
 
This may not be the correct response, your question is kind of vauge. Are
you talking about reading the html of a differnt page or the current page?

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim client As New System.Net.WebClient
Dim str As System.IO.Stream
str = client.OpenRead("http://www.amazon.com")
Dim reader As New System.IO.StreamReader(str)
Dim s As String = reader.ReadToEnd
Response.Write(s)
str.Close()
End Sub

note
 
Thanks, That is exactly what I was looking for!

Jared said:
This may not be the correct response, your question is kind of vauge. Are
you talking about reading the html of a differnt page or the current page?

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim client As New System.Net.WebClient
Dim str As System.IO.Stream
str = client.OpenRead("http://www.amazon.com")
Dim reader As New System.IO.StreamReader(str)
Dim s As String = reader.ReadToEnd
Response.Write(s)
str.Close()
End Sub

note
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top