在vb.net程序中冻结Http请求

时间:2011-09-15 16:36:08

标签: vb.net web-scraping

我刚刚制作了一个程序,我输入了代理列表,然后我的软件使用代理一遍又一遍地查看网址。我在程序旁边使用了一个Web浏览器,但运行缓慢。 所以我现在已经将代码更改为htpp请求。但是现在当我运行该程序时,它的视图会增加2,然后才会消失。 这是我的代码

 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    If ListBox1.Items.Count = 1 Then
        Timer1.Enabled = False
        MsgBox("All Proxies Used")

    Else

        Dim url As String = TextBox1.Text

        UseProxy(ListBox1.Items(itemnumber))



        Dim inStream As StreamReader
        Dim webRequest As WebRequest
        Dim webresponse As WebResponse
        Dim url2 As New System.Uri(TextBox1.Text)
        webRequest = webRequest.Create(url2)
        webresponse = webRequest.GetResponse()
        inStream = New StreamReader(webresponse.GetResponseStream())

        Dim myRequest As WebRequest = webRequest.Create(url2)
        Dim myResponse As WebResponse = myRequest.GetResponse()
        myResponse.Close()


        Label1.Text = ListBox1.Items.Count
        WebBrowser1.ScriptErrorsSuppressed = True
        Label6.Text = Label6.Text + 1
        Label5.Text = ListBox1.Items.Count * 15 / 60 & " Minutes"
    End If


End Sub

此外,我尝试只是去网站,而不是抓住任何使程序没有frezze但观点不会上升的东西

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    If ListBox1.Items.Count = 1 Then
        Timer1.Enabled = False
        MsgBox("All Proxies Used")

    Else

        Dim url As String = TextBox1.Text

        UseProxy(ListBox1.Items(itemnumber))



        Dim myRequest As WebRequest = WebRequest.Create(url)
        Dim myResponse As WebResponse = myRequest.GetResponse()
        myResponse.Close()


        Label1.Text = ListBox1.Items.Count
        WebBrowser1.ScriptErrorsSuppressed = True
        Label6.Text = Label6.Text + 1
        Label5.Text = ListBox1.Items.Count * 15 / 60 & " Minutes"
    End If


End Sub

所以尝试了两者但两者都不起作用