Return to Snippet

Revision: 63117
at April 9, 2013 19:22 by nimblebits


Initial Code
Function getPageSource(ByVal url As String) As String

        Dim sourcecode As String = String.Empty

        Try

            Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)
            Dim response As System.Net.HttpWebResponse = request.GetResponse()

            Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())

            sourcecode = sr.ReadToEnd()

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        Return sourcecode

    End Function

Initial URL

                                

Initial Description
You can use this to get the page source code of any valid URL. Tested on VS2010.

Initial Title
Get Page Source Code

Initial Tags
page, code

Initial Language
VB.NET