Results 1 to 3 of 3

Thread: Extracting links

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2004
    Location
    Newcastle
    Posts
    114

    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:
    1. 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:
    1. Private Sub webbrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    2. RichTextBox1.Text = WebBrowser1.Document.documentelement.innerhtml
    3. 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?

  2. #2
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Extracting links

    add a ref to the HTML Object Library

    VB Code:
    1. Dim HTMLDOC As HTMLDocument
    2.     Dim HTMLA As HTMLAnchorElement
    3.     Set HTMLDOC = WebBrowser1.Document
    4.     For Each HTMLA In HTMLDOC.links
    5.         List1.AddItem HTMLA.href
    6.     Next
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Extracting links from a WebBrowser Control

    Same technique but without any reference.
    VB Code:
    1. Private Sub Form_Load()
    2.     WebBrowser1.Navigate2 "http://www.vbforums.com"
    3. End Sub
    4.  
    5. '======================================================
    6.  
    7. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, _
    8.        URL As Variant)
    9.     Dim i As Integer
    10.     'Wait till document has loaded
    11.     If pDisp Is WebBrowser1.Object Then
    12.         'Loop through links
    13.         For i = 0 To WebBrowser1.Document.links.length - 1
    14.             List1.AddItem WebBrowser1.Document.links.Item(i).href
    15.         Next i
    16.     End If
    17. End Sub
    Last edited by iPrank; Feb 8th, 2007 at 10:37 PM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width