[RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source-VBForums
Results 1 to 22 of 22

Thread: [RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

  1. #1

    Thread Starter
    Lively Member nilesh16782's Avatar
    Join Date
    Feb 2007
    Location
    India
    Posts
    104

    Resolved [RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    hi all,,
    Is any method to get webbrowser html source code IN VB6..

    for this in .NET you can use this -- >WebBrowserObject.DocumentText
    but what for VB6...??


    plz help...

  2. #2
    PowerPoster
    Join Date
    Jan 2008
    Posts
    9,292

    Re: "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    For complet HTML source code use

    s = WebBrowser1.Document.documentelement.innerHTML

    for text only then use

    s = WebBrowser1.Document.documentelement.innertext


    There is also

    outerHTML and outerText. Just subsitute these to see exaclty what you get

  3. #3

    Thread Starter
    Lively Member nilesh16782's Avatar
    Join Date
    Feb 2007
    Location
    India
    Posts
    104

    Re: "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    WOW.. Thank you jmsrickland....now my problem is exaclty solved...

    Can you tell me how you detect 'documentelement.innerHTML' after 'Document'

    because when i write "WebBrowser1.Document." then quick list not shown in my VB..so how can i know "documentelement.innerHTML" or other property after document text...
    Last edited by nilesh16782; Feb 22nd, 2009 at 07:13 AM.

  4. #4
    PowerPoster
    Join Date
    Jan 2008
    Posts
    9,292

    Re: "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    I believe you'll find those in the object browser on your VB IDE but even if you do it won't really explain it. I learn these things from here by putting everything I can about WebBrowser I see here at this forum into a data base. There's just a ton of stuff around here about this.

  5. #5
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    Can you tell me how you detect 'documentelement.innerHTML' after 'Document'
    If you just want to use the inntellisense feature of vb6 on Document (IE DOM) element, first you have to reference the MSHTML.TBL (Microsoft HTML Object Library), then you just have to declare an object for HTMLDocument.

    vb Code:
    1. Option Explicit
    2. Private WB1doc As HTMLDocument
    3.  
    4. Private Sub Command1_Click()
    5.   'Will show you the html content. The Intellisense can be used on wb1doc.
    6.   Debug.Print WB1doc.documentElement.innerHTML
    7. End Sub
    8.  
    9. Private Sub Form_Load()
    10.   Me.Show: DoEvents
    11.   WebBrowser1.Navigate "http://www.google.com" 'go here
    12. End Sub
    13.  
    14. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    15.   Set WB1doc = WebBrowser1.Document 'each time you navigate in the webbrowser control is complete, the wb1doc object will be renewed once.
    16. End Sub

  6. #6

    Thread Starter
    Lively Member nilesh16782's Avatar
    Join Date
    Feb 2007
    Location
    India
    Posts
    104

    Re: "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    Yahhhhh ...thank Jim Davis and jmsrickland....
    Now My Problem totally solved...

    Onece again Thanks...

  7. #7
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    I'm just glad. Please set the thread as resolved.

  8. #8

    Thread Starter
    Lively Member nilesh16782's Avatar
    Join Date
    Feb 2007
    Location
    India
    Posts
    104

    Re: [RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    hi.....
    NOW i face a new problem...

    THINK.....
    ----------------------------
    A web page which has 3 frame and 3 images.

    Every frame and images has 3 different url address
    (which can see by 'Properties' of that frame/ image (after right click).
    --------------------------------

    BUTTTTTTTTTTTTTT
    now i want to asign 2nd frame or 2nd image url address in a Textbox by VB6 code..
    (Without clicking on webpage)??

    Possible..BUT HOW.?????????
    Last edited by nilesh16782; Feb 25th, 2009 at 08:30 AM.

  9. #9
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: [RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    By using the Frames() object array, you can retrieve each frame one by one. There, you can gain access to its content.

    http://www.comptechdoc.org/independe...javaframe.html

    http://www.w3schools.com/HTMLDOM/dom_obj_frame.asp

  10. #10
    PowerPoster
    Join Date
    Jan 2008
    Posts
    9,292

    Re: [RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    If the Frame has a name then
    Code:
    WebBrowser1.Document.frames("name-of-frame").Document.??????
    If the Frame does not have a name then use index. Zero means the 1st Frame and ????? means the object you are interested in within that frame
    Code:
    WebBrowser1.Document.frames(0).Document.??????
    Example, I am interested in a textbox within a frame that has a name
    Code:
    WebBrowser1.Document.frames("room").Document.All("userid").Value = txtUSER.Text
    If the Frame did not have a name and it was the 2nd Frame on the page then
    Code:
    WebBrowser1.Document.frames(1).Document.All("userid").Value = txtUSER.Text
    Last edited by jmsrickland; Feb 25th, 2009 at 09:24 AM.

  11. #11

    Thread Starter
    Lively Member nilesh16782's Avatar
    Join Date
    Feb 2007
    Location
    India
    Posts
    104

    Re: [RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    ok .. it's right..Thanks...


    Can u Tell me ...

    1.
    How can i fatches innertext / outerhtml of all frames of a web page..
    For more clear....
    I want to get data [fully innertext / all frames html code ] of a webpage which contain data in many frames/form]

    2.
    How i detect total frames of a webpage (Count frame/ forms / textbox of a webpage)
    is any method to know maximum index of a frames, forms, textbox, etc..??



    3.
    how can i Post Data of a form by WebBrowser1.Navegate or other method..
    For more clear..
    To login in yahoo account i want to direct post data of FORM which yahoo web page 'SignIn' Button post...

    Soooooooooooooo
    How it possible to singin by a function (like this..WebBrowser1.Navigate("URL") )to post uid and pass to a specific url Directely (no need to load login web page)...???
    Last edited by nilesh16782; Feb 26th, 2009 at 04:57 AM.

  12. #12
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: [RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    You have to download the sign in page, because there are a lots of hidden fields on yahoo page, that your browser control have to send/forward. It is because of yahoo security. However, you can fill in the form and press the submit button, all by 'programmatically'.

    There was a thread a few days ago, about the same experiment.
    http://www.vbforums.com/showthread.php?t=558027
    Last edited by Jim Davis; Feb 26th, 2009 at 04:27 AM.

  13. #13

    Thread Starter
    Lively Member nilesh16782's Avatar
    Join Date
    Feb 2007
    Location
    India
    Posts
    104

    Question Re: [RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    i read this thread...

    but sir i m not focus to directly login to yahoo account only..(it's just a example for suggest a web page for login..)

    i want to know how can i post/forword some values (like pressing a submit button which post data of a form) to a url ...through a function like this..

    ----> Webbrowser1.navigate("url",login=value1,pass=value2)

    ??

  14. #14
    PowerPoster
    Join Date
    Jan 2008
    Posts
    9,292

    Re: [RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    This is not intended to apply to any given website. It is example only and every website will have different format
    Code:
    WebBrowser1.Navigate "http://www.somesite.com/login.php?user=usermame&pass=password"
    Last edited by jmsrickland; Feb 27th, 2009 at 07:43 AM.

  15. #15
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: [RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    Unfortunately Yahoo will not accept the params in get properties, but you have to send them as form values, by using the post method.

    @nilesh: to get access to the restricted area of yahoo, it's not enough to simply send the username and password. There are a lots of hidden fields on the login form (in notepad, you will see them), that is sent by the server to the client when you download the login page, then your client have to pass the values back to the server, to get the proper authentication from yahoo, that gives you the full access. It is bit like the chapta, but it goes hidden, between the client and server.

  16. #16
    PowerPoster
    Join Date
    Jan 2008
    Posts
    9,292

    Re: [RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    Jim,

    He is telling you that Yahoo was just an example, not the actual website in question

  17. #17
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: [RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    I'm sorry, you are right. However, he is want to use this workaround for any kind of website. But, most of the login scripts are accept the username, even the password fields in POST data (form fields), that is cannot be sent in get properties (?prop=val&prop2=val2 ..etc is invalid). The only get properties that are exists, the page navigation decriptors, and sometimes a session id, but its irrevelant until he gets the access to a website.

    I also note here, that not every website uses "Username" and "Password" fields, but these are mostly, some uniquely named fields.
    Last edited by Jim Davis; Feb 27th, 2009 at 10:40 AM.

  18. #18
    PowerPoster
    Join Date
    Jan 2008
    Posts
    9,292

    Re: [RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    I also note here, that not every website uses "Username" and "Password" fields, but these are mostly, some uniquely named fields.

    Again, that was example only.

  19. #19

    Thread Starter
    Lively Member nilesh16782's Avatar
    Join Date
    Feb 2007
    Location
    India
    Posts
    104

    Question Re: [RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    (Sorry if any confusion in my question and THANKs for your valuable time...)
    Ok to more clear my problem i remove words which means "Forword/post Login-Password value to login a website.."

    i want post values to a URL...
    Like a user detail's webpage which fiill by user to create new account (that is just a example)....

    than normally i fill all textboxes and click submit button (which post value to specific url)

    BUTTTTTT
    i not want to goes this way .....
    i want to use a function (in VB6) LIKE this

    WebBrowser1.Navigate ("URL",text1.text,text2.text.....textN.text)
    OR
    FUNCTION("URL", text1.text,text2.text........textN.text)


    ...So how can achive this goal...??

    ??
    Last edited by nilesh16782; Feb 28th, 2009 at 09:04 AM.

  20. #20
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: [RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    You can use the IE DOM (WebBrowser1.Document) object, to access any parts of a html document you already got, or you can also use the *.Document.Write() method, to create a html document, that is you can access by using this object. You have to create a form tag that will include the appropirate fields you want to send, and then you have to fill in the values (or just create them by including their default value). Then, you can execute the submit button you created also, to submit the values to the page on the url you provided in the form tag.

    Visit w3schools.com website, to learn more about the form tags, just like the IE DOM object. But you can also google it for more examples, how javascript use it, and does webform automations.

  21. #21

    Thread Starter
    Lively Member nilesh16782's Avatar
    Join Date
    Feb 2007
    Location
    India
    Posts
    104

    Re: [RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    This is a way to make a html page via code and then work it like original page coding...

    But this method more complex to write such code (i think it's difficult to me).

    Navigate function have other optional parameter..
    Navigate( [Url as String], [flages], [TargetFrameName], [PostData], [Headers] )

    Can u tell me why this parameter use for...???
    Last edited by nilesh16782; Mar 1st, 2009 at 07:58 AM.

  22. #22
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: [RESOLVED] "WebBrowserObject.DocumentText" in "VB6" ...??? to view html source

    I'm sorry you are right!

    A search ( http://www.vbforums.com/search.php ) on the vbforums, drop me the result. You may also want to use the search function on the forums, instead of asking every single steps. Thats why the posts wont be deleted.

    http://www.vbforums.com/showpost.php...50&postcount=2

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.