My code works it does extract links, but these links are not what i expected to be extracted.
My program would extract links inside the <a href tag which contains a specific word which i can set manually.

Here is my complete code:

       Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim webClient As New System.Net.WebClient
            Dim WebSource As String = webClient.DownloadString("")

        Dim doc = New HtmlAgilityPack.HtmlDocument()
            Dim links = GetLinks(doc, "test")
            For Each Link In links
        End Sub

       Public Class Link
            Public Sub New(Uri As Uri, Text As String)
                Me.Uri = Uri
                Me.Text = Text
            End Sub
            Public Property Text As String
            Public Property Uri As Uri

            Public Overrides Function ToString() As String
                Return String.Format(If(Uri Is Nothing, "", Uri.ToString()))
            End Function
        End Class

        Public Function GetLinks(doc As HtmlAgilityPack.HtmlDocument, linkContains As String) As List(Of Link)
            Dim uri As Uri = Nothing
            Dim linksOnPage = From link In doc.DocumentNode.Descendants()
                              Where link.Name = "a" _
                              AndAlso link.Attributes("href") IsNot Nothing _
                              Let text = link.InnerText.Trim()
                              Let url = link.Attributes("href").Value
                              Where url.IndexOf(linkContains, StringComparison.OrdinalIgnoreCase) >= 0 _
                              AndAlso uri.TryCreate(url, UriKind.Absolute, uri)

            Dim Uris As New List(Of Link)()
            For Each link In linksOnPage
                Uris.Add(New Link(New Uri(link.url, UriKind.Absolute), link.text))

            Return Uris
        End Function

I want to extract all links which contains the word "test"
Here is the URL i am extracting links from:

My expected output:‎‎‎‎‎‎

My actual output (it is so different with my expected output):

Yes it does extract links which contains the word "test" but these are not the links i want to be extracted.
where did i go wrong? I am really confused right now. I have been stuck with this problem for 2 weeks already.
I really need help.

After doing a quick view source of google - it looks like what you really want is wrapped inside <cite> </cite> tags, and not href.

Be a part of the DaniWeb community

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