如何让webclient连接thouhg socks5代理?
问题描述:
因为标题说我希望我的webclient与socks5代理连接
So as the title says I want my webclient to connect with socks5 proxies
WebProxy wp = new WebProxy(socks5 proxy);
client1.Proxy = wp;
client1.DownloadString("someurl")
答
您好BataBo Jokviu,
Hi BataBo Jokviu,
感谢您发布此处。
对于您的问题,您可以尝试使用该代码下面。
For your question, you could try the code below.
//NameSpace: System.Net
using ( WebClient wc = new WebClient () )
{
WebProxy wp = new WebProxy ( "Proxy server IP address: proxy server port" ), true );
if (/*Proxy server does not authenticate*/)
{
wp.Credentials = CredentialCache.DefaultCredentials;
}
else
{
wp.Credentials = new NetworkCredential("UserName", "PassWord");
}
wc.Proxy = wp; //Designated agent
wc.Encoding = System.Text.Encoding.Default;
//wc.DownloadString(....)
//wc.OpenWrite()
}
最诚挚的问候,
Wendy