Solved

WebBrowser control getting links

Posted on 2004-09-25
6
1,717 Views
Last Modified: 2008-01-09
I am trying to get all the links from an html page.  I am running into
difficulties on pages that have "frames".  I realize there might be issues
with framed sites but the site I'm interested in doesn't actually have
frames but does have asp header and side menus and I think that is the
problem.  It chokes on this line of code and gives me error 438: Object does
not support this property or method.

WebBrowser1.Document.links.length - 1

That's just plain weird because if you Add Watch to the WebBrowser control
and drill down the tree, it shows it to you!  What is going on here?
0
Comment
Question by:wym
6 Comments
 
LVL 10

Expert Comment

by:anv
Comment Utility
0
 

Author Comment

by:wym
Comment Utility
Thanks for answering but that's where I got my sample from in the first place.  It just doesn't like WebBrowser1.Document.links.length-1 on a site encased in headers and side menu.  I've seen so many other various samples and I'm shocked that no one ever came across a site they couldn't strip and found an alternative?

This is ALL my code.

Private Sub Command1_Click()

Open "links.txt" For Append As #1

For x = 0 To WebBrowser1.Document.links.length - 1
    If Left(WebBrowser1.Document.links(x), 26) = "http://www.osfi-bsif.gc.ca" Then
        Print #1, WebBrowser1.Document.links.Item(x)
    End If
Next x
Close #1
MsgBox "done"
End Sub

Private Sub Command2_Click()
WebBrowser1.Navigate2 Text1.Text
End Sub
0
 
LVL 11

Expert Comment

by:bingie
Comment Utility
Whats the original URL?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:wym
Comment Utility
This URL won't work

http://www.osfi-bsif.gc.ca/eng/publications/guidance/index_prudential.asp

But this URL will:

http://www.osfi-bsif.gc.ca/eng/publications/guidance/prudential.asp

I haven't figured out how to strip the frames off the home page but it's this:

http://www.osfi-bsif.gc.ca/eng/default.asp
0
 
LVL 14

Accepted Solution

by:
aelatik earned 50 total points
Comment Utility
I think the method for enumeration is the problem, this one is working on all 3 URL's !

Private Sub Command1_Click()
        'WebBrowser1.Navigate "http://www.osfi-bsif.gc.ca/eng/default.asp"
        'WebBrowser1.Navigate "http://www.osfi-bsif.gc.ca/eng/publications/guidance/prudential.asp"
        WebBrowser1.Navigate "http://www.osfi-bsif.gc.ca/eng/publications/guidance/index_prudential.asp"
        While WebBrowser1.Busy: DoEvents: Wend
        Open "c:\links.txt" For Append As #1
        For i = 0 To WebBrowser1.Document.All.length - 1
            If UCase(WebBrowser1.Document.All(i).Tagname) = "A" Then
                If LCase(Left(WebBrowser1.Document.All(i).Href, 26)) = LCase("http://www.osfi-bsif.gc.ca") Then
                    Print #1, WebBrowser1.Document.All(i).Href
                End If
            End If
        Next
        Close #1
        MsgBox " done"
End Sub
0
 

Author Comment

by:wym
Comment Utility
Excellent!  Thanks a lot!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now