|
|
Title | Read the links on a Web page |
Keywords | Web, URL, link, WebBrowser |
Categories | Controls |
|
|
Use the WebBrowser control's Navigate method to load a Web page. When the document finishes loading, loop through the WebBrowser1.Document.links collection to examine the link objects.
Note that this program sets a reference to the Microsoft HTML Object Library.
|
|
Private Sub cmdLoad_Click()
txtLinks.Text = ""
Screen.MousePointer = vbHourglass
DoEvents
WebBrowser1.Navigate txtURL
' The rest happens in WebBrowser1_DocumentComplete.
End Sub
Private Sub WebBrowser1_DownloadComplete()
Dim doc As HTMLDocument
Dim a_link As HTMLAnchorElement
Dim txt As String
' List the links.
On Error Resume Next
Set doc = WebBrowser1.Document
For Each a_link In doc.links
txt = txt & a_link.href & vbCrLf
Next a_link
txtLinks.Text = txt
Screen.MousePointer = vbDefault
End Sub
|
|
|
|
|
|