Posted By

blackf0rk on 03/12/09


parse html page return web

Versions (?)

Return HTML from a Web page

 / Published in: VB.NET


If you need to get the HTML from a Web page to rip it, process it, and/or display it in the way you want, the following function will work for you.

  1. Public Function GetHTML(ByVal sURL As String, ByVal e As Integer) As String
  2. Dim oHttpWebRequest As System.Net.HttpWebRequest
  3. Dim oStream As System.IO.Stream
  4. Dim sChunk As String
  5. oHttpWebRequest = (System.Net.HttpWebRequest.Create(sURL))
  6. Dim oHttpWebResponse As System.Net.WebResponse = oHttpWebRequest.GetResponse()
  7. oStream = oHttpWebResponse.GetResponseStream
  8. sChunk = New System.IO.StreamReader(oStream).ReadToEnd()
  9. oStream.Close()
  10. oHttpWebResponse.Close()
  11. If e = 0 Then
  12. Return Server.HtmlEncode(sChunk)
  13. Else
  14. Return Server.HtmlDecode(sChunk)
  15. End If
  16. End Function

Report this snippet  

You need to login to post a comment.