-
Apr 12th, 2006, 10:09 AM
#1
Thread Starter
Lively Member
Extracting links
sup guys, haveing mega problems trying to grab links from google. well what im trying to do is navigate to google with a link like
VB Code:
WebBrowser1.Navigate "http://www.google.co.uk/search?hl=en&q=" & text1.text & "&meta="
Example ^^^
now what im trying to do is write all the links to a listbox or richtextbox with all the link results from the innerhtml, see below
VB Code:
Private Sub webbrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
RichTextBox1.Text = WebBrowser1.Document.documentelement.innerhtml
End Sub
now this saves the inner html to what ever i want it to eg a listbox or richtextbox, does anyone know how i can loop and print the links to another richtextbox with the searchwords i typed into google?
-
Apr 12th, 2006, 10:20 AM
#2
Re: Extracting links
add a ref to the HTML Object Library
VB Code:
Dim HTMLDOC As HTMLDocument
Dim HTMLA As HTMLAnchorElement
Set HTMLDOC = WebBrowser1.Document
For Each HTMLA In HTMLDOC.links
List1.AddItem HTMLA.href
Next
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 12th, 2006, 10:37 AM
#3
Extracting links from a WebBrowser Control
Same technique but without any reference.
VB Code:
Private Sub Form_Load()
WebBrowser1.Navigate2 "http://www.vbforums.com"
End Sub
'======================================================
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, _
URL As Variant)
Dim i As Integer
'Wait till document has loaded
If pDisp Is WebBrowser1.Object Then
'Loop through links
For i = 0 To WebBrowser1.Document.links.length - 1
List1.AddItem WebBrowser1.Document.links.Item(i).href
Next i
End If
End Sub
Last edited by iPrank; Feb 8th, 2007 at 10:37 PM.
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
|