|
-
Jun 14th, 2007, 07:58 AM
#1
Thread Starter
Lively Member
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?
-
Jun 14th, 2007, 08:21 AM
#2
Fanatic Member
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.
-
Jun 14th, 2007, 09:59 AM
#3
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
-
Jun 14th, 2007, 12:06 PM
#4
Thread Starter
Lively Member
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?
-
Jun 14th, 2007, 12:32 PM
#5
Lively Member
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:
dim i
for i = 0 to totalsearches
dim linkStart, link, linkEnd
LinkStart = InStr(1 + LinkLast, html, " - <a href=""") + 12
Link = Mid(html, LinkStart)
LinkEnd = InStr(1, Link, """") - 1
Link = Mid(Link, 1, LinkEnd)
If LinkLast < (LinkStart + LinkEnd) Then
LinkLast = LinkStart + LinkEnd
End If
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|