Solved

WebBrowser control getting links

Posted on 2004-09-25
6
1,723 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
ID: 12150029
0
 

Author Comment

by:wym
ID: 12151400
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
ID: 12151841
Whats the original URL?
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:wym
ID: 12152246
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
ID: 12153706
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
ID: 12156769
Excellent!  Thanks a lot!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

786 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