Return HTML from a Web page


/ Published in: VB.NET
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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

URL: http://codefinds.blogspot.com/2009/01/return-html-from-web-page.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.