Solved

WebBrowser control getting links

Posted on 2004-09-25
6
1,727 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

856 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