|
-
Feb 28th, 2004, 11:11 PM
#1
Thread Starter
Lively Member
WebBrowser control - get all html including head content
I'm using a WebBrowser control to get the HTML code of a webpage. But, right now it only returns me the contents of the body. How can I also grab the head content (I want to javascript too).
This is what I do now: (wbWeb is my WebBrowser control, and strhtml is the web page HTML I want)
wbWeb.Navigate(psURL)
Do While wbWeb.ReadyState <> 4 '= READYSTATE_COMPLETE
Application.DoEvents()
Sleep(500)
Loop
strhtml = wbWeb.Document.body.outerhtml
Any help is appreciated! Thanks in advance!
-
Feb 29th, 2004, 07:34 AM
#2
you should be using DocumentElement not Body , also if you try typing wbWeb.Document.body.outerhtml with Option Strict turned on it'll error , you need to add a reference to the mshtml dll.
here's an example ...
VB Code:
'/// you must add a reference to the Microsoft html object library.
AxWebBrowser1.Navigate("about:home")
While Not AxWebBrowser1.ReadyState = SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE
Application.DoEvents()
End While
Dim objHtml As mshtml.HTMLDocumentClass = DirectCast(AxWebBrowser1.Document, mshtml.HTMLDocumentClass)
Dim strHtml As String = objHtml.documentElement.outerHTML
MessageBox.Show(strHtml)
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|