Reputation: 161
I'm running the following code to check rank code from a website. This code works fine before my country banned that website. Now it works fine if I'm using proxy or VPN on my pc. So how to set manual proxy (proxies from TheBannedSite.com and ports) in that app on a default proxy setting from pc.
Code:
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
I tried following code:
Dim str As New System.Net.WebClient
str.Proxy = System.Net.HttpWebRequest.DefaultWebProxy
Dim Coder As String = str.DownloadString((url))
but it set dafult proxy of my pc. I want manual proxy...
Upvotes: 1
Views: 5402
Reputation: 27322
You need to create a WebProxy object, specify the appropriate properties and assign this as the str.Proxy:
Dim prox As New System.Net.WebProxy
prox.Address = New Uri(...)
prox.Credentials = New System.Net.NetworkCredential(...)
str.Proxy = prox
Upvotes: 1