Results 1 to 5 of 5

Thread: Check HTML Source Multiple Times

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    113

    Check HTML Source Multiple Times

    Code:
    StrData = Inet1.OpenURL("http://www.sample.com/blah.php")
    
    Test = Mid(StrData, InStr(1, StrData, "<a href=" & """") + Len("<a href=" & """") + 1)
    Test = Mid(Test, 1, InStr(1, Test, """") - 1)
    
    MsgBox Test
    This code searches through the HTML of a website and displays anything inside the first <a href="[THIS IS DISPLAYED]"> tag.

    The problem is it only displays what's in the FIRST tag. I'd like the code to search through the entire HTML and display every <a href tag.

    Can anyone help?

  2. #2
    Fanatic Member robbedaya's Avatar
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    872

    Re: Check HTML Source Multiple Times

    somthing like this
    Code:
    Dim pos as integer
    pos = 1
    Do While pos <> 0
        pos = InStr(pos, StrData, "<a href=" & Chr(34))
        If pos > 0 Then
            MsgBox Mid(StrData, pos + Len("<a href=" & Chr(34)) + 1)
            pos = pos + 1
        End If
    Loop
    - Use the thread tools to Mark your Thread as Resolved when your question is answered.
    - Please Rate my answers if they where helpful.

  3. #3
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Check HTML Source Multiple Times

    Give this a try. Place a Webbrowser control on your form and then set a reference to "Microsoft Internet Controls"
    Code:
    Private Sub Form_Load()
    Dim objHTML As HTMLDocument
    Dim objAnchor As HTMLAnchorElement
    
        WebBrowser1.Visible = False
        WebBrowser1.navigate "http://www.dell.com"
        Set objHTML = WebBrowser1.document
        
        
        For Each objAnchor In objHTML.links
            Debug.Print objAnchor.href
        Next objAnchor
       
        Set objHTML = Nothing
    End Sub

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    113

    Re: Check HTML Source Multiple Times

    I enabled the Microsoft Internet Control reference and it gave me some User-defined error. I then tried enabling the Microsoft HTML Object Library to see if that would help but now it says Object variable or With block variable not set.

    Any ideas?

  5. #5
    Lively Member
    Join Date
    Jan 2007
    Posts
    95

    Re: Check HTML Source Multiple Times

    recently i made a programme of song's lyrics search... in that programme i used a website which searches for lyrics... i was also having this problem but i solved it by using my BRAIN but in that, i know that how many links were there...
    my programme first search for "Total Results: " and get the number of links in the same way u did in ur first post (djwk) and then i use 'for loop'...
    here is the code:
    vb Code:
    1. dim i
    2. for i = 0 to totalsearches
    3.             dim linkStart, link, linkEnd
    4.            
    5.             LinkStart = InStr(1 + LinkLast, html, " - <a href=""") + 12
    6.             Link = Mid(html, LinkStart)
    7.             LinkEnd = InStr(1, Link, """") - 1
    8.             Link = Mid(Link, 1, LinkEnd)
    9.  
    10.             If LinkLast < (LinkStart + LinkEnd) Then
    11.                 LinkLast = LinkStart + LinkEnd
    12.             End If
    13. next
    here 'html' is the website's html...AND DONT FORGET TO RATE THIS POST IF THIS HELPS YOU!

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