Results 1 to 13 of 13

Thread: how to get HTML source from web control?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    362

    how to get HTML source from web control?

    I have a web control in my application. I use it to login gmail. The web control shows the emails I have. How can I get the HTML source of the page the web control is showing?

    thanks

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: how to get HTML source from web control?


  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    362

    Re: how to get HTML source from web control?

    Quote Originally Posted by dglienna
    thanks. however, it does not work.

    I use:
    VB Code:
    1. Dim MyDoc As mshtml.IHTMLDocument2
    2. Set MyDoc = wb.Document
    3.  
    4. dim strTmp as string
    5. strTmp = MyDoc.body.innerHTML

    to get the HTML, however, it only returns some simple notification text although I can see the page in the web control.

    do not know why.


    thanks again

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: how to get HTML source from web control?

    Funny but when i look at the source of gmail's page i can see this:
    VB Code:
    1. function el(id) {
    2.   if (document.getElementById) {
    3.     return document.getElementById(id);
    4.   } else if (window[id]) {
    5.     return window[id];
    6.   }
    7.   return null;

    which looks like the java even uses DOM, cause this is DOM

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    362

    Re: how to get HTML source from web control?

    Quote Originally Posted by dglienna
    Funny but when i look at the source of gmail's page i can see this:
    VB Code:
    1. function el(id) {
    2.   if (document.getElementById) {
    3.     return document.getElementById(id);
    4.   } else if (window[id]) {
    5.     return window[id];
    6.   }
    7.   return null;

    which looks like the java even uses DOM, cause this is DOM
    then, what I should do? thanks.

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: how to get HTML source from web control?

    Post the page that you are having trouble with, and let theVader look at it.
    I'm sure he'll be along. Also post any code that you are using, or having trouble with.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    362

    Re: how to get HTML source from web control?

    Quote Originally Posted by dglienna
    Post the page that you are having trouble with, and let theVader look at it.
    I'm sure he'll be along. Also post any code that you are using, or having trouble with.
    The webpage is gmail.com. I use below code to login. In the web control, it shows that I login successfully. And I can see these emails. If I use right-click->'view source', I can see the source which includes the information of these emails. However, How can I get this source in VB6 program? when I use MyDoc.body.innerHTML, gets nothing except a short notification.

    thanks

    VB Code:
    1. Private Sub wb_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    2.    
    3.     Dim MyDoc As mshtml.IHTMLDocument2
    4.     Set MyDoc = wb.Document
    5.    
    6.             If Not MyDoc Is Nothing Then
    7.                 MyDoc.All.Item("Email").Value = strUserName
    8.                 MyDoc.All.Item("Passwd").Value = strPassword
    9.                
    10.                 MyDoc.Forms.Item("gaia_loginform").submit
    11.                
    12.            End If
    13.  
    14.     Set MyDoc = nothing
    15. end sub

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: how to get HTML source from web control?

    I've PM'd him for you.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    362

    Re: how to get HTML source from web control?

    Quote Originally Posted by dglienna
    I've PM'd him for you.
    thanks you very much


    I appreciate your help

  10. #10
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: how to get HTML source from web control?

    If you want to get an email list out of Gmail, you need to be using the "basic HTML" view, instead of the standard view which is JavaScript and therefore doesn't show the page content in the source code.

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    362

    Re: how to get HTML source from web control?

    Quote Originally Posted by penagate
    If you want to get an email list out of Gmail, you need to be using the "basic HTML" view, instead of the standard view which is JavaScript and therefore doesn't show the page content in the source code.
    thanks. it seems i have to load the 'standard view' first, then use basic html. So that, can get the HTML contents. Is there any other better approach?

    thanks again

  12. #12
    New Member
    Join Date
    Jun 2011
    Posts
    10

    Re: how to get HTML source from web control?

    If you have a webbrowser control on your form and you just want to see the source then do this:

    Code:
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
         Dim DocText As String
         Me.WebBrowser1.Navigate("http://www.google.com")
         DocText = Me.WebBrowser1.DocumentText
    End Sub
    If you want to automate the Webpage then do this:

    'You Have To Go Online To The Page You Want To Automate And Look At The Source In This Case Im Going To Yahoo! And Im Looking For The Search Input Box And Submit Button...

    'Yahoo Source Code:
    '<input id="p_30345635-p" name="p" type="text" title="Search" value="Search" autocomplete="off" class="input-query y-ln-3 y-txt-input">

    'And

    '<button style="" class="searchsubmit med-large y-fp-pg-grad" value="Web Search" type="submit" id="search-submit">Web Search</button>

    Code:
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
         Dim EleSearchBox As Windows.Forms.HtmlElement
         Dim EleSearchButton As Windows.Forms.HtmlElement
    
         WebBrowser1.Navigate("http://www.yahoo.com")
    
         'We Have To Wait For The WebBrowser To Load...
         Do
              My.Application.DoEvents()
         Loop Until FormAPABuddy.WebBrowser1.ReadyState = WebBrowserReadyState.Complete
    
         EleSearchBox = WebBrowser1.Document.GetElementById("p_30345635-p")
         EleSearchButton = WebBrowser1.Document.GetElementById("search-submit")
         EleSearchButton.InvokeMember("onclick")
    End Sub
    Thank You,
    SGT Larry G. Ransom III

  13. #13

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