Get List of all Links on a Web Page - Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This tutorial desribes how to get a list of all links on webpage in Visual Basic .NET

Add a Webbrowser, a Button, a textbox and a label to the form:

Change the Webbrowser Url Properties to the page you want to get its links: (ex: http://www.google.com)

In this tutorial, we will get the links on Google page:

Get all links code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim a As Integer
        Dim b As String
        For a = 1 To WebBrowser1.Document.Links.Count - 1
            b = b & WebBrowser1.Document.Links(a).InnerHtml & vbCrLf
        Next

        TextBox1.Text = b
        Label1.Text = WebBrowser1.Document.Links.Count & " links."
    End Sub


Share This

Home | About | Contact | Privacy Policy

Copyright visual-basic-tutorials.com 2017 - All Rights Reserved.