I'm a beginner and like to know how do you get all links in browser1 and display them in a listbox

Recommended Answers

All 2 Replies

Hi,

Toget link from the Webpage you have to parse the Htmlcode of the webpage(you need to download the webpage first)

i assumed that you have the HTML code in a text box, then simly look for the tag <a href>
The links usually provided in this tag only, the text proceeding after "=" symbol and between the double quates is the link content, store the link in a array, continue further for collecting links in the webpage.

After creating the array , load the array elements to you list/Combobox.


Hope this will help you,


With regards
Venkatramasamy SN

On a blank form, add the following controls

1. Listbox
2. WebBrowser Control
3. Command Button

Add a project reference to "Microsoft HTML Object Library"

Private Sub Command1_Click()
    Dim oHTMLDoc As MSHTML.HTMLDocument
    Dim oHTMLElement As MSHTML.IHTMLElement
    
    WebBrowser1.navigate "http://www.google.com/"

    Do
        DoEvents
    Loop Until WebBrowser1.readyState = READYSTATE_COMPLETE
    
    Set oHTMLDoc = WebBrowser1.document
    
    For Each oHTMLElement In oHTMLDoc.links
        List1.AddItem oHTMLElement
    Next
    
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.