Advertisement
Kyfx

Proxy Checker

Mar 14th, 2015
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1.  
  2. Imports System.IO
  3. Imports System.Net
  4. Public Class Form1
  5. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  6. Dim fo As New OpenFileDialog
  7. fo.RestoreDirectory = True
  8. fo.Multiselect = False
  9. fo.Filter = "txt files (*.txt)|*.txt"
  10. fo.FilterIndex = 1
  11. fo.ShowDialog()
  12. If (Not fo.FileName = Nothing) Then
  13. Dim proxies As New List(Of String)
  14. Using sr As New StreamReader(fo.FileName)
  15. While sr.Peek <> -1
  16. proxies.Add(sr.ReadLine())
  17. End While
  18. End Using
  19. Dim myProxy As WebProxy
  20. For Each proxy As String In proxies
  21. Try
  22. myProxy = New WebProxy(proxy)
  23. Dim r As HttpWebRequest = HttpWebRequest.Create("http://www.google.com")
  24. r.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36"
  25. r.Timeout = 3000
  26. r.Proxy = myProxy
  27. Dim re As HttpWebResponse = r.GetResponse()
  28. ListBox1.Items.Add("Working Proxy: " & proxy)
  29. Catch ex As Exception
  30. ListBox1.Items.Add("Unresponsive Proxy: " & proxy)
  31. End Try
  32. Next
  33. End If
  34. End Sub
  35.  
  36. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  37. If (ListBox1.Items.Count > 0) Then
  38. Dim fs As New SaveFileDialog
  39. fs.RestoreDirectory = True
  40. fs.Filter = "txt files (*.txt)|*.txt"
  41. fs.FilterIndex = 1
  42. fs.ShowDialog()
  43. If Not (fs.FileName = Nothing) Then
  44. Using sw As New StreamWriter(fs.FileName)
  45. For Each line As String In ListBox1.Items
  46. sw.WriteLine(line)
  47. Next
  48. End Using
  49. End If
  50. End If
  51. End Sub
  52.  
  53. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  54. If (ListBox1.Items.Count > 0) Then
  55. Dim fs As New SaveFileDialog
  56. fs.RestoreDirectory = True
  57. fs.Filter = "txt files (*.txt)|*.txt"
  58. fs.FilterIndex = 1
  59. fs.ShowDialog()
  60. If Not (fs.FileName = Nothing) Then
  61. Using sw As New StreamWriter(fs.FileName)
  62. For Each line As String In ListBox1.Items
  63. If (line.StartsWith("Working Proxy: ")) Then sw.WriteLine(line)
  64. Next
  65. End Using
  66. End If
  67. End If
  68. End Sub
  69. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement