problem with vb.net and webbrowser, scraping

-1

I'm making an application with vb.net with the webbrowser object.

Basically I do the following automatically, nevego a direction, I scrolling down to load the entire page (since it is dynamic and load as you scroll down) and finally I take the data I want.

The problem is that if all this is done automatically, it does not load the whole page, but I do all three actions in the same order by pressing three buttons if it loads it completely. I do not know why motive in doing the scrolling the webbrowser stays as blocked. but if I do it by pressing a button there is no problem. I've put breaks between actions but they do not solve the problem

Sytem.Threading.Thread.Sleep(2000)

edit:

WebOC.Navigate(link)
    Do While WebOC.ReadyState <> WebBrowserReadyState.Complete
        System.Windows.Forms.Application.DoEvents()
    Loop

for i = 1 to 2
        webOc.Document.Window.ScrollTo(0, i*3000)
        Do While Form2.WebBrowser1.ReadyState <> WebBrowserReadyState.Complete
                System.Windows.Forms.Application.DoEvents()
        Loop
next i

---- after I extract the data, that if the page is fully loaded it works

    
asked by loosserman 31.01.2018 в 14:25
source

1 answer

0

This code is the one that has worked for me, I'm not clear on why, what I do know is that in the other way the browser was blocked and could not load the page, so we stopped the webbrowser's load, and this way, while the pause acts the webbrowser does not stop.

Private Sub Pausa(ByVal segundos As Double)
    Dim esperaTmp As Long = My.Computer.Clock.TickCount + (segundos * 1000)
    While esperaTmp > My.Computer.Clock.TickCount
        System.Windows.Forms.Application.DoEvents()
    End While
End Sub 
    
answered by 02.02.2018 / 00:56
source