WebBrowser1.Navigate循环请求

时间:2016-12-20 12:35:55

标签: vb.net

在通过这些链接运行一次之后,如何使此代码在Webbrowser1中连续循环URL。

这是我到目前为止的代码,但是当我运行此代码时,Webbrowser会停止使用最后一个网址,这是google.com。我想要做的是当达到最后一个网址时,我希望它再次从顶部开始,并一次又一次地运行链接,直到我退出程序。

Public Class Form1

Private WithEvents backgroundWorker1 As System.ComponentModel.BackgroundWorker

Dim l As New List(Of String)
Dim flagDC As Boolean = False

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Button1.Hide()
    Button3.Show()
    l = New List(Of String)
    l.Add("http://bbc.com/sipeu/php/zq.php")
    l.Add("http://google.com")
    l.Add("http://DCWC.com/sipeu/us.php")
    l.Add("http://google.com")
    l.Add("http://example.com/sipeu/v.php")
    l.Add("http://google.com")

    backgroundWorker1 = New System.ComponentModel.BackgroundWorker
    backgroundWorker1.RunWorkerAsync()
End Sub

Private Sub BackgroundWorker2_DoWork(ByVal sender As System.Object,
                                     ByVal e As System.ComponentModel.DoWorkEventArgs) _
                                     Handles backgroundWorker1.DoWork
    For Each www In l
        flagDC = False
        WebBrowser1.Navigate(www)
        Do

        Loop While Not flagDC



    Next

End Sub

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object,
                                          ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) _
                                          Handles WebBrowser1.DocumentCompleted

    System.Threading.Thread.Sleep(1000)

    flagDC = True

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Button3.Hide()
    ChangeUserAgent("troll001_v2-agent34")

    WebBrowser1.Navigate("http://example.com/welcome.php")


End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
    Close()
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs)
End Sub

0 个答案:

没有答案