hoangbn000111
Lead Gen Expert
LEVEL 1
300 XP
Introduction:
This tutorial will be on how to create a proxy checker which will test a list of proxies and report if they respond within 3000ms/3seconds (can be changed using .Timeout).
Steps of Creation:
Step 1:
First we will need to Import two packages, one to use StreamReader and StreamWriter and another to use HttpWebRequest and HttpWebResponse
Step 2:
Add a listbox and three buttons. The listbox will contains the reports of each proxy and the button will be for; Starting the checker, Exporting all the reports and Exporting the working reports
First lets make the start script. Let's create an openFileDialog to select a proxy list and check the path isn't nothing/null/empty:
Step 3:
Now let's create a new "proxies" String List and add all the lines of the file in to the list.
Step 3:
For the last bit of the checking script let's 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".
Step 4:
Now let's make a quick export all script. A simple script to select a save file, iterate through all the items in the listbox and write the line to the file using StreamWriter:
Step 5:
Now for the export working proxies script. It's the exact same as the export all script except we want to check if the line starts with "Working Proxy: ". Alternatively we could setup a list and when we check them we could add the working ones to a list and read that.
Project Completed!
That's it! Below is the source code and you can download the project from the attached files below.
Download
This tutorial will be on how to create a proxy checker which will test a list of proxies and report if they respond within 3000ms/3seconds (can be changed using .Timeout).
Steps of Creation:
Step 1:
First we will need to Import two packages, one to use StreamReader and StreamWriter and another to use HttpWebRequest and HttpWebResponse
- Imports System.IO
- Imports System.Net
Step 2:
Add a listbox and three buttons. The listbox will contains the reports of each proxy and the button will be for; Starting the checker, Exporting all the reports and Exporting the working reports
First lets make the start script. Let's create an openFileDialog to select a proxy list and check the path isn't nothing/null/empty:
- Private
Sub
Button1_Click(sender As
Object
, e As
EventArgs) Handles Button1.Click
- Dim
fo As
New
OpenFileDialog
- fo.RestoreDirectory = True
- fo.Multiselect = False
- fo.Filter = "txt files (*.txt)|*.txt"
- fo.FilterIndex = 1
- fo.ShowDialog()
- If
(Not
fo.FileName = Nothing
) Then
- End
If
- End
Sub
Step 3:
Now let's create a new "proxies" String List and add all the lines of the file in to the list.
- Private
Sub
Button1_Click(sender As
Object
, e As
EventArgs) Handles Button1.Click
- Dim
fo As
New
OpenFileDialog
- fo.RestoreDirectory = True
- fo.Multiselect = False
- fo.Filter = "txt files (*.txt)|*.txt"
- fo.FilterIndex = 1
- fo.ShowDialog()
- If
(Not
fo.FileName = Nothing
) Then
- Dim
proxies As
New
List(Of String
)
- Using sr As
New
StreamReader(fo.FileName)
- While
sr.Peek <> -1
- proxies.Add(sr.ReadLine())
- End
While
- End
Using
- End
If
- End
Sub
Step 3:
For the last bit of the checking script let's 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".
- Private
Sub
Button1_Click(sender As
Object
, e As
EventArgs) Handles Button1.Click
- Dim
fo As
New
OpenFileDialog
- fo.RestoreDirectory = True
- fo.Multiselect = False
- fo.Filter = "txt files (*.txt)|*.txt"
- fo.FilterIndex = 1
- fo.ShowDialog()
- If
(Not
fo.FileName = Nothing
) Then
- Dim
proxies As
New
List(Of String
)
- Using sr As
New
StreamReader(fo.FileName)
- While
sr.Peek <> -1
- proxies.Add(sr.ReadLine())
- End
While
- End
Using
- Dim
myProxy As
WebProxy
- For
Each
proxy As
String
In
proxies
- Try
- myProxy = New
WebProxy(proxy)
- Dim
r As
HttpWebRequest = 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
- Dim
re As
HttpWebResponse = r.GetResponse()
- ListBox1.Items.Add("Working Proxy: "
& proxy)
- Catch ex As
Exception
- ListBox1.Items.Add("Unresponsive Proxy: "
& proxy)
- End
Try
- Next
- End
If
- End
Sub
Step 4:
Now let's make a quick export all script. A simple script to select a save file, iterate through all the items in the listbox and write the line to the file using StreamWriter:
- Private
Sub
Button2_Click(sender As
Object
, e As
EventArgs) Handles Button2.Click
- If
(ListBox1.Items.Count > 0) Then
- Dim
fs As
New
SaveFileDialog
- fs.RestoreDirectory = True
- fs.Filter = "txt files (*.txt)|*.txt"
- fs.FilterIndex = 1
- fs.ShowDialog()
- If
Not
(fs.FileName = Nothing
) Then
- Using sw As
New
StreamWriter(fs.FileName)
- For
Each
line
As
String
In
ListBox1.Items
- sw.WriteLine(line
)
- Next
- End
Using
- End
If
- End
If
- End
Sub
Step 5:
Now for the export working proxies script. It's the exact same as the export all script except we want to check if the line starts with "Working Proxy: ". Alternatively we could setup a list and when we check them we could add the working ones to a list and read that.
- Private
Sub
Button3_Click(sender As
Object
, e As
EventArgs) Handles Button3.Click
- If
(ListBox1.Items.Count > 0) Then
- Dim
fs As
New
SaveFileDialog
- fs.RestoreDirectory = True
- fs.Filter = "txt files (*.txt)|*.txt"
- fs.FilterIndex = 1
- fs.ShowDialog()
- If
Not
(fs.FileName = Nothing
) Then
- Using sw As
New
StreamWriter(fs.FileName)
- For
Each
line
As
String
In
ListBox1.Items
- If
(line
.StartsWith("Working Proxy: "
)) Then
sw.WriteLine(line
)
- Next
- End
Using
- End
If
- End
If
- End
Sub
Project Completed!
That's it! Below is the source code and you can download the project from the attached files below.
- Imports System.IO
- Imports System.Net
- Public
Class Form1
- Private
Sub
Button1_Click(sender As
Object
, e As
EventArgs) Handles Button1.Click
- Dim
fo As
New
OpenFileDialog
- fo.RestoreDirectory = True
- fo.Multiselect = False
- fo.Filter = "txt files (*.txt)|*.txt"
- fo.FilterIndex = 1
- fo.ShowDialog()
- If
(Not
fo.FileName = Nothing
) Then
- Dim
proxies As
New
List(Of String
)
- Using sr As
New
StreamReader(fo.FileName)
- While
sr.Peek <> -1
- proxies.Add(sr.ReadLine())
- End
While
- End
Using
- Dim
myProxy As
WebProxy
- For
Each
proxy As
String
In
proxies
- Try
- myProxy = New
WebProxy(proxy)
- Dim
r As
HttpWebRequest = 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
- Dim
re As
HttpWebResponse = r.GetResponse()
- ListBox1.Items.Add("Working Proxy: "
& proxy)
- Catch ex As
Exception
- ListBox1.Items.Add("Unresponsive Proxy: "
& proxy)
- End
Try
- Next
- End
If
- End
Sub
- Private
Sub
Button2_Click(sender As
Object
, e As
EventArgs) Handles Button2.Click
- If
(ListBox1.Items.Count > 0) Then
- Dim
fs As
New
SaveFileDialog
- fs.RestoreDirectory = True
- fs.Filter = "txt files (*.txt)|*.txt"
- fs.FilterIndex = 1
- fs.ShowDialog()
- If
Not
(fs.FileName = Nothing
) Then
- Using sw As
New
StreamWriter(fs.FileName)
- For
Each
line
As
String
In
ListBox1.Items
- sw.WriteLine(line
)
- Next
- End
Using
- End
If
- End
If
- End
Sub
- Private
Sub
Button3_Click(sender As
Object
, e As
EventArgs) Handles Button3.Click
- If
(ListBox1.Items.Count > 0) Then
- Dim
fs As
New
SaveFileDialog
- fs.RestoreDirectory = True
- fs.Filter = "txt files (*.txt)|*.txt"
- fs.FilterIndex = 1
- fs.ShowDialog()
- If
Not
(fs.FileName = Nothing
) Then
- Using sw As
New
StreamWriter(fs.FileName)
- For
Each
line
As
String
In
ListBox1.Items
- If
(line
.StartsWith("Working Proxy: "
)) Then
sw.WriteLine(line
)
- Next
- End
Using
- End
If
- End
If
- End
Sub
- End
Class
Download
You must upgrade your account or reply in the thread to view hidden text.