Proxy Checker using C#
Submitted by donbermoy on Tuesday, July 15, 2014 - 23:08.
In this tutorial, we will create a proxy checker program which will test a list of proxies and report if they respond within a faster time.
Now, let's start this tutorial!
1. Let's start with creating a Windows Form Application in C# for this tutorial by following the following steps in Microsoft Visual Studio 2010: Go to File, click New Project, and choose Windows Application.
2. Next, add three buttons for starting the checker, exporting all the reports and exporting the working reports; add also a ListBox that will contain the reports of each proxy.
3. Import these two namespaces.
4. For Button1, put this code below to select a proxy list and check the path isn't nothing/null/empty.
Then let's create a new proxies in the String List and add all the lines of the file in to the list in Button1.
Now for the checking of script we will create a HTTPWebRequest to Google, set the proxy to the current address and set a timeout for the request of receiving the response to 3000ms/3seconds. If it gets a response it will continue and add the proxy as Working to the list box, otherwise it will catch the error and report it as Unresponsive.
5. For Button2, put this code below to make a quick export all script.
6. Lastly for Button3, put this code below to export working proxies script.
Full source code:
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
If you have some queries, feel free to contact the number or e-mail below.
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
- using System.IO;
- using System.Net;
- private void Button1_Click(object sender, EventArgs e)
- {
- fo.RestoreDirectory = true;
- fo.Multiselect = false;
- fo.Filter = "txt files (*.txt)|*.txt";
- fo.FilterIndex = 1;
- fo.ShowDialog();
- if (fo.FileName != null)
- {
- }
- }
- private void Button1_Click(object sender, EventArgs e)
- {
- fo.RestoreDirectory = true;
- fo.Multiselect = false;
- fo.Filter = "txt files (*.txt)|*.txt";
- fo.FilterIndex = 1;
- fo.ShowDialog();
- if (fo.FileName != null)
- {
- {
- while (sr.Peek != -1)
- {
- proxies.Add(sr.ReadLine());
- }
- }
- }
- }
- private void Button1_Click(object sender, EventArgs e)
- {
- fo.RestoreDirectory = true;
- fo.Multiselect = false;
- fo.Filter = "txt files (*.txt)|*.txt";
- fo.FilterIndex = 1;
- fo.ShowDialog();
- if (fo.FileName != null)
- {
- {
- while (sr.Peek != -1)
- {
- proxies.Add(sr.ReadLine());
- }
- }
- WebProxy myProxy = default(WebProxy);
- foreach (string proxy in proxies)
- {
- try
- {
- HttpWebRequest r = HttpWebRequest.Create("http://www.google.com");
- r.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36";
- r.Timeout = 3000;
- r.Proxy = myProxy;
- HttpWebResponse re = r.GetResponse();
- ListBox1.Items.Add("Working Proxy: " + proxy);
- }
- catch (Exception)
- {
- ListBox1.Items.Add("Unresponsive Proxy: " + proxy);
- }
- }
- }
- }
- private void Button2_Click(object sender, EventArgs e)
- {
- if (ListBox1.Items.Count > 0)
- {
- fs.RestoreDirectory = true;
- fs.Filter = "txt files (*.txt)|*.txt";
- fs.FilterIndex = 1;
- fs.ShowDialog();
- if (!(fs.FileName == null))
- {
- {
- foreach (string line in ListBox1.Items)
- {
- sw.WriteLine(line);
- }
- }
- }
- }
- }
- private void Button3_Click(object sender, EventArgs e)
- {
- if (ListBox1.Items.Count > 0)
- {
- fs.RestoreDirectory = true;
- fs.Filter = "txt files (*.txt)|*.txt";
- fs.FilterIndex = 1;
- fs.ShowDialog();
- if (!(fs.FileName == null))
- {
- {
- foreach (string line in ListBox1.Items)
- {
- if (line.StartsWith("Working Proxy: "))
- {
- sw.WriteLine(line);
- }
- }
- }
- }
- }
- }
- using System.IO;
- using System.Net;
- public class Form1
- {
- private void Button1_Click(object sender, EventArgs e)
- {
- fo.RestoreDirectory = true;
- fo.Multiselect = false;
- fo.Filter = "txt files (*.txt)|*.txt";
- fo.FilterIndex = 1;
- fo.ShowDialog();
- if (fo.FileName != null)
- {
- {
- while (sr.Peek() != -1)
- {
- proxies.Add(sr.ReadLine());
- }
- }
- WebProxy myProxy = default(WebProxy);
- foreach (string proxy in proxies)
- {
- try
- {
- HttpWebRequest r = HttpWebRequest.Create("http://www.google.com");
- r.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36";
- r.Timeout = 3000;
- r.Proxy = myProxy;
- HttpWebResponse re = r.GetResponse();
- ListBox1.Items.Add("Working Proxy: " + proxy);
- }
- catch (Exception)
- {
- ListBox1.Items.Add("Unresponsive Proxy: " + proxy);
- }
- }
- }
- }
- private void Button2_Click(object sender, EventArgs e)
- {
- if (ListBox1.Items.Count > 0)
- {
- fs.RestoreDirectory = true;
- fs.Filter = "txt files (*.txt)|*.txt";
- fs.FilterIndex = 1;
- fs.ShowDialog();
- if (!(fs.FileName == null))
- {
- {
- foreach (string line in ListBox1.Items)
- {
- sw.WriteLine(line);
- }
- }
- }
- }
- }
- private void Button3_Click(object sender, EventArgs e)
- {
- if (ListBox1.Items.Count > 0)
- {
- fs.RestoreDirectory = true;
- fs.Filter = "txt files (*.txt)|*.txt";
- fs.FilterIndex = 1;
- fs.ShowDialog();
- if (!(fs.FileName == null))
- {
- {
- foreach (string line in ListBox1.Items)
- {
- if (line.StartsWith("Working Proxy: "))
- {
- sw.WriteLine(line);
- }
- }
- }
- }
- }
- }
- }
Comments
Add new comment
- Add new comment
- 1784 views