我正在运行以下代码来检查网站的排名代码。在我的国家禁止该网站之前,此代码正常工作。现在,如果我在我的电脑上使用代理或VPN,它工作正常。那么如何在pc上的默认代理设置中设置该应用程序中的手动代理(来自TheBannedSite.com和端口的代理)。
代码:
Try
Dim str As String = New WebClient().DownloadString((url))
Dim pattern = "When asked enter the code: <font color=blue>(\d{5,})\s<\/font>"
Dim r = New Regex(pattern, RegexOptions.IgnoreCase)
Dim m As Match = r.Match(str)
If m.Success Then
FlatLabel1.Text = "Code:: " + m.Groups(1).ToString()
m = m.NextMatch()
'Captcha1.Refresh()
Else
FlatLabel1.Text = "Please Check ur Network Connection First !!"
End If
Catch
Interaction.MsgBox("Please Check ur Network Connection First !! ", MsgBoxStyle.Information, "Error")
End Try
我尝试了以下代码:
Dim str As New System.Net.WebClient
str.Proxy = System.Net.HttpWebRequest.DefaultWebProxy
Dim Coder As String = str.DownloadString((url))
但它设置了我的电脑的dafult代理。 我想要手动代理...
答案 0 :(得分:0)
您需要创建一个WebProxy对象,指定适当的属性并将其指定为str.Proxy:
Dim prox As New System.Net.WebProxy
prox.Address = New Uri(...)
prox.Credentials = New System.Net.NetworkCredential(...)
str.Proxy = prox