|
-
Jun 20th, 2006, 05:26 AM
#1
Thread Starter
Addicted Member
Good-old, chewed up topic about WebBrowser contol, getting it further down the road
Browsing MS website, I found this page:
http://www.microsoft.com/technet/arc....mspx?mfr=true
which talkes about the WebBrowser control and its usage.
Let me quote one thing from that page:
Controlling what content is downloaded. You do this by implementing the download control ambient property, which can restrict frames, images, Java, and so on.
This is exactly what I wanted. Below you can see few parts of my code, where I use WebBrowser to download HTML code and the contents of the page like links, etc. What I needed is to restrict WebBrowser from downloading and executing JavaScript, Flash, ActiveX, and all other useless to me items. I guess thit is what I quoted out from MS site, but how would I implement this?
VB Code:
Option Explicit
Dim WithEvents myWeb As SHDocVw.InternetExplorer
Private Sub Command1_Click()
Set myWeb = New SHDocVw.InternetExplorer 'create new WebBrowser control
myWeb.Navigate "http://www.yahoo.com" 'go there
Do While myWeb.ReadyState <> READYSTATE_COMPLETE
DoEvents '
Loop
Text1 = myWeb.Document.documentElement.innerHTML 'grab HTML codes
'do some other stuff here
Text2 = myWeb.Document.documentElement.innerText 'grab the contents without HTML
'do some more stuff, blah, blah
Set myWeb = Nothing 'trash the page
'do something else
End Sub
Private Sub myWeb_NewWindow2(ppDisp As Object, Cancel As Boolean)
Set ppDisp = Nothing
Cancel = True
End Sub
Private Sub myWeb_StatusTextChange(ByVal Text As String)
On Error Resume Next
'this speeds things up, cause you never know what other content will load on that page
Dim ssnvar, re
ssnvar = myWeb.Document.documentElement.innerHTML
Set re = New RegExp
re.Pattern = "</body>"
re.Global = True
re.IgnoreCase = True
If re.test(ssnvar) = True Then myWeb.Stop
End Sub
To play with the above code you dont need WebBrowser control on your form, just add references to "Microsoft VBScript Regular Expressions 5.5" and "Microsoft Internet Controls". 1 Command button, and 2 Text boxes with Multiline property = True.
Last edited by foxter; Jun 20th, 2006 at 06:24 AM.
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
|