gypsyjoe11
Registered User.
- Local time
- Today, 17:07
- Joined
- Feb 19, 2010
- Messages
- 46
Hi I made a program that people might want to use. It recursively gets all the tags in a HTML document.
Below is the another program that checks all open IE browsers for the right one and then calls the above subroutine.
People could modify it to print out the innerHTML or outerHTML or search for text. *Note - You have to press the stop(reset) button in your VB editor in order for it to finish making the text file. It seems to hold some in the buffer until you press stop. I can't close the file inside the routine because it uses recursion.
Code:
Public Sub SearchDom(myFrame As HTMLDocument, myFile As String, Optional mySpace As String = "")
On Error Resume Next
Open myFile For Append As #1
For i = 0 To myFrame.all.Length - 1
Print #1, mySpace & myFrame.all(i).tagName
SearchDom myFrame.all(i), myFile, mySpace & " "
Next
End Sub
Below is the another program that checks all open IE browsers for the right one and then calls the above subroutine.
Code:
Public Sub testFind()
'find the right internet explorer webpage
Dim allExplorerWindows As New SHDocVw.ShellWindows
Set allExplorerWindows = New SHDocVw.ShellWindows
Dim IEwindow As SHDocVw.InternetExplorer
Dim foundFlag As Boolean
foundFlag = False
For Each IEwindow In allExplorerWindows
If InStr(IEwindow.LocationURL, ".direct-access.us") <> 0 Then
foundFlag = True
Exit For 'found the right IE window URL
End If
Next
If Not foundFlag Then
Dim DisplayBox As VbMsgBoxResult
DisplayBox = MsgBox("Could not find an open instance running.", vbOKOnly, "Error!")
Exit Sub
End If
'end find
'get the pages entire main IE document
Dim mainDoc As HTMLDocument
Set mainDoc = IEwindow.document
SearchDom mainDoc, "Z:\JWClifford\Home\myHTML.txt"
End Sub
People could modify it to print out the innerHTML or outerHTML or search for text. *Note - You have to press the stop(reset) button in your VB editor in order for it to finish making the text file. It seems to hold some in the buffer until you press stop. I can't close the file inside the routine because it uses recursion.