我正在使用luminati代理,该代理使用基本身份验证。 要使用其他ip,您只需要在凭据中设置其他用户名,如下所示: my-username-ip-183.xxx.xxx.xxx,指定新的ip
但是,webclient继续使用您提供给它的第一个证书(在示例中,i = 0)。 我想这是缓存问题吗? 有趣的是,如果我在代码中放置一个断点,它会完美运行
for (int i = 0; i < username.Length; i++)
{
using (WebClient client = new WebClient())
{
WebProxy proxy = new WebProxy(ip:port);
proxy.Credentials = new NetworkCredential(username[i], password);
client.Proxy = proxy;
string MyIp = client.DownloadString("http://any site that tells your ip");
if (username[i].Contains(MyIp) == false)
{
MessageBox.Show("error");
}
}
}
我在SO中发现的唯一类似问题是这个,但是在Java中 Multithreading with Java's htmlunit.WebClient and multiple proxies