using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Net; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Web; namespace ProxyChecker { internal class Program { private static void Main(string[] args) { string path = "C:\\users\\zsolt\\desktop\\proxies.txt"; //string path = args[0]; List<string> proxies = File.ReadLines(path).ToList(); Parallel.ForEach(proxies, proxy => { WebProxy myproxy = new WebProxy(proxy); WebRequest myWebRequest = WebRequest.Create("http://www.google.com"); myWebRequest.Timeout = 3000; myWebRequest.Proxy = myproxy; WebResponse myWebResponse = myWebRequest.GetResponse(); myWebResponse.Close(); try { using (WebResponse response = myWebRequest.GetResponse()) { HttpWebResponse httpResponse = (HttpWebResponse) response; Console.WriteLine(proxy, httpResponse.StatusCode); } } catch (WebException e) { using (WebResponse response = e.Response) { HttpWebResponse httpResponse = (HttpWebResponse) response; Console.WriteLine("Error code: {0}", httpResponse.StatusCode); using (Stream data = response.GetResponseStream()) { string text = new StreamReader(data).ReadToEnd(); Console.WriteLine(proxy, text); } } } }); Console.Read(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)