Hello, I read the token from the site a certain number of times. tell me how to take a new proxy every time you log into the cycle All proxies are stored in a text file. This is what I do:

static CookieDictionary cook = new CookieDictionary(); String token = string.Empty; string GET(string url)//получение токена { var Proxy = File.ReadLines("proxy.txt").ToList(); var count = Proxy.Count; for (int i = 0; i < (int)numericUpDown1.Value; i++) { foreach (var list in Proxy) { System.Threading.Thread.Sleep(500); var request = new HttpRequest(); request.UserAgent = HttpHelper.ChromeUserAgent(); request.Proxy = HttpProxyClient.Parse(list); request.Cookies = cook; HttpResponse response = request.Get(url); var z = response.ToString(); Match res = Regex.Match(z, "var AUTH_TOKEN = \"(.*)\";"); token = res.Groups[1].ToString(); } } return token; } 

but all proxies are loaded at once into the list variable when prompted, how to ensure that the next proxy is taken at each cycle entry?

    1 answer 1

     foreach (var list in Proxy) 
     var list = Proxy[i % Proxy.Count]; 
    • anyway, every time you log into the cycle, it takes all proxies at once (is there another way? - inkorpus
    • What cycle? This line is instead of a loop. - Qwertiy
    • I realized that this is instead of foreach. but the for loop remained. at each entry to the for list immediately all ip are downloaded - inkorpus
    • Careful ... - Qwertiy
    • Try running the code yourself and see what will be in the debug) - inkorpus