C#使用WebClient的代理
这是我现在掌握的密码C#使用WebClient的代理,c#,proxy,webclient,C#,Proxy,Webclient,这是我现在掌握的密码 using (WebClient client = new WebClient()) { Console.WriteLine(client.DownloadString("http://bot.whatismyipaddress.com/")); } 现在,我想为代理添加两个选项 标准IP:Proxy的一个选项 带有身份验证的选项 我似乎不知道如何将它与上面的代码连接起来 using (WebClient client = new WebClient()
using (WebClient client = new WebClient())
{
Console.WriteLine(client.DownloadString("http://bot.whatismyipaddress.com/"));
}
现在,我想为代理添加两个选项
using (WebClient client = new WebClient()) {
client.Proxy = new WebProxy("31.4.5.26", 8080); // proxy's host,port
client.Proxy.Credentials = new NetworkCredential("proxyuser", "proxypassword");
Console.WriteLine(client.DownloadString("http://bot.whatismyipaddress.com/"));
}
对我来说很好