var proxylist = project.Lists["p"];
var result = project.Lists["res"];
var error = project.Lists["error"];
string[] additionalHeaders = {
"Accept-Language: " + project.Profile.AcceptLanguage,
"Accept: " + project.Profile.HTTPAccept,
"Accept-Encoding: " + project.Profile.AcceptEncoding,
};
ParallelLoopResult loopResult = Parallel.For(0, 100, x => {
var proxy = "";
lock (CommonCode.pl)
{
proxy = proxylist[0];
proxylist.RemoveAt(0);
}
string res = "";
try
{
res = ZennoPoster.HttpGet("http://2ip.ru/", "http://" + proxy, "UTF-8", ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.HeaderAndBody, 50000, "", "", true, 3, additionalHeaders);
}
catch
{
lock (CommonCode.res)
{
error.Add(proxy);
}
}
if(!string.IsNullOrEmpty(res))
{
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(res);
var item = doc.DocumentNode.SelectSingleNode(@"//div[@class='ip']").InnerText;
if (item != null)
{
lock (CommonCode.res)
{
result.Add(items);
}
}
}
});