How to copy html source code of url loaded in webbrowser controle?
Hi could any one show me how i can can get the html source code of currently loaded url in a webbrowser controle ? i want to place that html in a textbox for further process. Looking forward for replies.Thanks
Re: How to copy html source code of url loaded in webbrowser controle?
This should work.
Code:
Private Sub Command1_Click()
Dim strURL As String
Dim objHTML
strURL = WebBrowser1.LocationURL
Set objHTML = CreateObject("Microsoft.XMLHTTP")
objHTML.open "GET", strURL, False
objHTML.send
Text1.Text = objHTML.responseText
Set objHTML = Nothing
End Sub
Re: How to copy html source code of url loaded in webbrowser controle?
Another way:
Code:
Option Explicit
Private Sub Form_Load()
WebBrowser1.Navigate "www.google.com"
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim sHTMLSource As String 'the HTML
Dim sHTMLAsText As String 'the text
If (pDisp Is WebBrowser1.object) Then
sHTMLSource = pDisp.Document.documentElement.innerHTML
sHTMLAsText = pDisp.Document.documentElement.innerText
Debug.Print sHTMLSource
End If
End Sub