Results 1 to 3 of 3

Thread: How to copy html source code of url loaded in webbrowser controle?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    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

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    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

  3. #3
    Fanatic Member
    Join Date
    Mar 2009
    Posts
    804

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width