Basically, I found out that my web requests are only using the same proxy over and over in a web scraping project I'm doing.
public static List<string> proxyLogs = new List<string>();
private static Random random = new Random();
public static string randomizeProxy(List<string> proxies = null)
{
if (proxies == null)
proxies = proxyLogs;
return proxies[random.Next(proxies.Count)];
}
Parallel.ForEach(concurrentLogs, new ParallelOptions { MaxDegreeOfParallelism = 4}, log =>
{
//my http requests
string proxyLog = randomizeProxy(proxyLogs);
Console.WriteLine(proxyLog);
});
So the parallel option thread is set to 4, the 4 requests its doing is using the same proxy over and over and not different for each thread.
What seems to be the best approach for this?