Results 1 to 3 of 3

Thread: VB - Internet - General - Snippet - Extract URLs from Webpages

  1. #1

    Thread Starter
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849

    VB - Internet - General - Snippet - Extract URLs from Webpages

    This snippet shoes how to extract all the URLs displayed in a webpage. Requirements

    1) A WebBrowser Component
    2) A reference to the Microsoft HTML Object Library

    VB Code:
    1. Dim objHTML As New MSHTML.HTMLDocument
    2.  
    3. Private Sub Form_Load()
    4. WB.navigate "http://www.vbforums.com"
    5. End Sub
    6.  
    7. Private Sub WB_DownloadComplete()
    8.     Set objHTML = WB.document
    9.     For i = 0 To objHTML.links.Length - 1
    10.         Debug.Print objHTML.links(i)
    11.     Next i
    12. End Sub

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  2. #2
    Fanatic Member
    Join Date
    Feb 2003
    Posts
    599

    Topic continue

    Private Sub WB_DownloadComplete()
    Set objHTML = WB.document
    For i = 0 To objHTML.links.Length - 1
    Debug.Print objHTML.links(i)
    Next i
    End Sub

    kay jay !!

    how to rectify the problem... if the objhtml is empty ? an error might appear that is error '91'

    when i doi :

    if objhtml <> "" then
    Thank You

  3. #3

    Thread Starter
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849

    Re: Topic continue

    Originally posted by vbnew
    kay jay !!

    how to rectify the problem... if the objhtml is empty ? an error might appear that is error '91'

    when i doi :

    if objhtml <> "" then
    U should check for
    VB Code:
    1. If objHTML Is Nothing Then
    as objHTML is an object and not equate it with a string value

    PS: Pls continue or post anew in the General Section, or PM/E-Mail me.

    Regards

    KayJay

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

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