How to view HTML source of any webpage using VB.net?
This code will provide you HTML source of any webpage. You can parse it as per your requirement.
GET method is used to retrieve information which is identified by the Request URI.
I hope it will be useful for you all.
Description:
If you want to display any webpage of your intrasite page then proxy setting are not required.
If you want to display HTML source in the textbox then "Multiline" property has to be set as true.
Imports System.IO
Imports System.Net
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strURL As String
Dim strResult As String
Dim myrequest As HttpWebRequest
Dim myresponse As HttpWebResponse
Dim sr As StreamReader
strURL = "your_intra_sitename"
myrequest = WebRequest.Create(strURL)
myrequest.Method = "GET"
Dim netCredential As New System.Net.NetworkCredential()
myrequest.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
myresponse = myrequest.GetResponse
sr = New StreamReader(myresponse.GetResponseStream)
strResult = sr.ReadToEnd
TextBox1.Text = strResult
sr.Close()
End Sub
End Class