Return to Snippet

Revision: 12384
at March 12, 2009 17:07 by blackf0rk


Initial Code
Public Function GetHTML(ByVal sURL As String, ByVal e As Integer) As String
   Dim oHttpWebRequest As System.Net.HttpWebRequest
   Dim oStream As System.IO.Stream
   Dim sChunk As String
   oHttpWebRequest = (System.Net.HttpWebRequest.Create(sURL))
   Dim oHttpWebResponse As System.Net.WebResponse = oHttpWebRequest.GetResponse()
   oStream = oHttpWebResponse.GetResponseStream
   sChunk = New System.IO.StreamReader(oStream).ReadToEnd()
   oStream.Close()
   oHttpWebResponse.Close()
   If e = 0 Then
      Return Server.HtmlEncode(sChunk)
   Else
      Return Server.HtmlDecode(sChunk)
   End If
End Function

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

Initial Description
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.

Initial Title
Return HTML from a Web page

Initial Tags
html, page, web

Initial Language
VB.NET