Web Page Question

Devon Nullman 21 Reputation points
2021-11-08T21:59:14.193+00:00

I want to grab the available links on a webpage that displays search results. I am using System.Net.WebRequest to load the data then I parse it.

The problem is that the page only shows 24 hits and if there are more than 24, you must scroll to the bottom to get another 6 or displayed.

Is there any way to simulate the scrolling ? If I had to, I could load the page into a Web Browser.

Developer technologies | VB
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jiachen Li-MSFT 34,231 Reputation points Microsoft External Staff
    2021-11-09T06:02:56.367+00:00

    Hi @Devon Nullman ,
    If you load the page into a Web Browser, you can use the code below to grab the available links.

        Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted  
            For Each ClientControl As HtmlElement In WebBrowser1.Document.Links  
                Dim href As String = ClientControl.GetAttribute("href").ToString  
                If href.Contains("https://") Then  
                    ListBox1.Items.Add(href)  
                End If  
            Next  
        End Sub  
    

    Hope the code above could be helpful.
    Best Regards.
    Jiachen Li
    *
    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.