vb.net中的HttpWebRequest代理

时间:2018-12-28 11:21:25

标签: c# vb.net httpwebrequest

该代理中的问题,但我要代码,如果代理失败,请返回以从列表框中选择新代理的启动代码,而无需停止我的程序,然后重新启动,现在如果一个代理失败,我又可以重新开始,请浪费时间,我希望你了解我。

私有子线程任务(作为IEnumerable(字符串)的lstProxies)

    'iam want code to go back here if proxy fail, and select new proxy from my listbox
    For Each s As String In lstProxies

        Dim request As HttpWebRequest

        Dim datastring As String
        Dim login As String = thelogin(lstProxies)
        Dim emails As String = TextBox1.Text

        ServicePointManager.DefaultConnectionLimit = 100
        CheckForIllegalCrossThreadCalls = False
        request = CType(WebRequest.Create("https://test.com"), HttpWebRequest)
        request.Proxy = New WebProxy(s, True)
        request.Method = "POST"
        request.CookieContainer = cookieJar
        'here is Erorr Could not connect to remote server proxy not work
        Using postStream As Stream = request.GetRequestStream()
            Dim byteArray As Byte() = System.Text.Encoding.UTF8.GetBytes("id=" & login + "&email=" & emails)
            postStream.Write(byteArray, 0, byteArray.Length)
        End Using
        Using stream = New StreamReader(request.GetResponse().GetResponseStream())
            datastring = stream.ReadToEnd()
        End Using




        If datastring.Contains("succesfully") Then
            MessageBox.Show("found")
        ElseIf datastring.Contains("fail") Then
            MessageBox.Show("fail")
        Else
            TextBox3.Text = ("none")

        End If
    Next


End Sub

HERE image code

0 个答案:

没有答案