• We just launched and are currently in beta. Join us as we build and grow the community.

Visual Basic Proxy Checker

hoangbn000111

Lead Gen Expert
H Rep
0
0
0
Rep
0
H Vouches
0
0
0
Vouches
0
Posts
87
Likes
67
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
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

  1. Imports System.IO
  2. 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:

  1. Private

    Sub

    Button1_Click(sender As

    Object

    , e As

    EventArgs) Handles Button1.Click
  2. Dim

    fo As

    New

    OpenFileDialog
  3. fo.RestoreDirectory = True
  4. fo.Multiselect = False
  5. fo.Filter = "txt files (*.txt)|*.txt"
  6. fo.FilterIndex = 1
  7. fo.ShowDialog()
  8. If

    (Not

    fo.FileName = Nothing

    ) Then
  9. End

    If
  10. 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.

  1. Private

    Sub

    Button1_Click(sender As

    Object

    , e As

    EventArgs) Handles Button1.Click
  2. Dim

    fo As

    New

    OpenFileDialog
  3. fo.RestoreDirectory = True
  4. fo.Multiselect = False
  5. fo.Filter = "txt files (*.txt)|*.txt"
  6. fo.FilterIndex = 1
  7. fo.ShowDialog()
  8. If

    (Not

    fo.FileName = Nothing

    ) Then
  9. Dim

    proxies As

    New

    List(Of String

    )
  10. Using sr As

    New

    StreamReader(fo.FileName)
  11. While

    sr.Peek <> -1
  12. proxies.Add(sr.ReadLine())
  13. End

    While
  14. End

    Using
  15. End

    If
  16. 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".

  1. Private

    Sub

    Button1_Click(sender As

    Object

    , e As

    EventArgs) Handles Button1.Click
  2. Dim

    fo As

    New

    OpenFileDialog
  3. fo.RestoreDirectory = True
  4. fo.Multiselect = False
  5. fo.Filter = "txt files (*.txt)|*.txt"
  6. fo.FilterIndex = 1
  7. fo.ShowDialog()
  8. If

    (Not

    fo.FileName = Nothing

    ) Then
  9. Dim

    proxies As

    New

    List(Of String

    )
  10. Using sr As

    New

    StreamReader(fo.FileName)
  11. While

    sr.Peek <> -1
  12. proxies.Add(sr.ReadLine())
  13. End

    While
  14. End

    Using
  15. Dim

    myProxy As

    WebProxy
  16. For

    Each

    proxy As

    String

    In

    proxies
  17. Try
  18. myProxy = New

    WebProxy(proxy)
  19. Dim

    r As

    HttpWebRequest = HttpWebRequest.Create("http://www.google.com"

    )
  20. r.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36"
  21. r.Timeout = 3000
  22. r.Proxy = myProxy
  23. Dim

    re As

    HttpWebResponse = r.GetResponse()
  24. ListBox1.Items.Add("Working Proxy: "

    & proxy)
  25. Catch ex As

    Exception
  26. ListBox1.Items.Add("Unresponsive Proxy: "

    & proxy)
  27. End

    Try
  28. Next
  29. End

    If
  30. 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:

  1. Private

    Sub

    Button2_Click(sender As

    Object

    , e As

    EventArgs) Handles Button2.Click
  2. If

    (ListBox1.Items.Count > 0) Then
  3. Dim

    fs As

    New

    SaveFileDialog
  4. fs.RestoreDirectory = True
  5. fs.Filter = "txt files (*.txt)|*.txt"
  6. fs.FilterIndex = 1
  7. fs.ShowDialog()
  8. If

    Not

    (fs.FileName = Nothing

    ) Then
  9. Using sw As

    New

    StreamWriter(fs.FileName)
  10. For

    Each

    line

    As

    String

    In

    ListBox1.Items
  11. sw.WriteLine(line

    )
  12. Next
  13. End

    Using
  14. End

    If
  15. End

    If
  16. 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.

  1. Private

    Sub

    Button3_Click(sender As

    Object

    , e As

    EventArgs) Handles Button3.Click
  2. If

    (ListBox1.Items.Count > 0) Then
  3. Dim

    fs As

    New

    SaveFileDialog
  4. fs.RestoreDirectory = True
  5. fs.Filter = "txt files (*.txt)|*.txt"
  6. fs.FilterIndex = 1
  7. fs.ShowDialog()
  8. If

    Not

    (fs.FileName = Nothing

    ) Then
  9. Using sw As

    New

    StreamWriter(fs.FileName)
  10. For

    Each

    line

    As

    String

    In

    ListBox1.Items
  11. If

    (line

    .StartsWith("Working Proxy: "

    )) Then

    sw.WriteLine(line

    )
  12. Next
  13. End

    Using
  14. End

    If
  15. End

    If
  16. End

    Sub

Project Completed!
That's it! Below is the source code and you can download the project from the attached files below.

  1. Imports System.IO
  2. Imports System.Net
  3. Public

    Class Form1
  4. Private

    Sub

    Button1_Click(sender As

    Object

    , e As

    EventArgs) Handles Button1.Click
  5. Dim

    fo As

    New

    OpenFileDialog
  6. fo.RestoreDirectory = True
  7. fo.Multiselect = False
  8. fo.Filter = "txt files (*.txt)|*.txt"
  9. fo.FilterIndex = 1
  10. fo.ShowDialog()
  11. If

    (Not

    fo.FileName = Nothing

    ) Then
  12. Dim

    proxies As

    New

    List(Of String

    )
  13. Using sr As

    New

    StreamReader(fo.FileName)
  14. While

    sr.Peek <> -1
  15. proxies.Add(sr.ReadLine())
  16. End

    While
  17. End

    Using
  18. Dim

    myProxy As

    WebProxy
  19. For

    Each

    proxy As

    String

    In

    proxies
  20. Try
  21. myProxy = New

    WebProxy(proxy)
  22. Dim

    r As

    HttpWebRequest = HttpWebRequest.Create("http://www.google.com"

    )
  23. r.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36"
  24. r.Timeout = 3000
  25. r.Proxy = myProxy
  26. Dim

    re As

    HttpWebResponse = r.GetResponse()
  27. ListBox1.Items.Add("Working Proxy: "

    & proxy)
  28. Catch ex As

    Exception
  29. ListBox1.Items.Add("Unresponsive Proxy: "

    & proxy)
  30. End

    Try
  31. Next
  32. End

    If
  33. End

    Sub

  34. Private

    Sub

    Button2_Click(sender As

    Object

    , e As

    EventArgs) Handles Button2.Click
  35. If

    (ListBox1.Items.Count > 0) Then
  36. Dim

    fs As

    New

    SaveFileDialog
  37. fs.RestoreDirectory = True
  38. fs.Filter = "txt files (*.txt)|*.txt"
  39. fs.FilterIndex = 1
  40. fs.ShowDialog()
  41. If

    Not

    (fs.FileName = Nothing

    ) Then
  42. Using sw As

    New

    StreamWriter(fs.FileName)
  43. For

    Each

    line

    As

    String

    In

    ListBox1.Items
  44. sw.WriteLine(line

    )
  45. Next
  46. End

    Using
  47. End

    If
  48. End

    If
  49. End

    Sub

  50. Private

    Sub

    Button3_Click(sender As

    Object

    , e As

    EventArgs) Handles Button3.Click
  51. If

    (ListBox1.Items.Count > 0) Then
  52. Dim

    fs As

    New

    SaveFileDialog
  53. fs.RestoreDirectory = True
  54. fs.Filter = "txt files (*.txt)|*.txt"
  55. fs.FilterIndex = 1
  56. fs.ShowDialog()
  57. If

    Not

    (fs.FileName = Nothing

    ) Then
  58. Using sw As

    New

    StreamWriter(fs.FileName)
  59. For

    Each

    line

    As

    String

    In

    ListBox1.Items
  60. If

    (line

    .StartsWith("Working Proxy: "

    )) Then

    sw.WriteLine(line

    )
  61. Next
  62. End

    Using
  63. End

    If
  64. End

    If
  65. End

    Sub
  66. End

    Class


Download
You must upgrade your account or reply in the thread to view hidden text.
 

452,292

323,526

323,535

Top