Guest User

[VB] Code Get Web Proxy List - HungVB.Com

a guest
Sep 23rd, 2021
24
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Net
  2. Imports System.Text.RegularExpressions
  3. Imports System.Threading
  4. Imports System.Windows.Forms
  5. Public Class Form1
  6.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  7.         Try
  8.             Dim webc As New WebClient
  9.             webc.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0")
  10.             Dim src As String = webc.DownloadString(TextBox1.Text)
  11.             Dim reg As Regex = New Regex("[0-9]*?\.[0-9]*?\.[0-9]*?\.[0-9]+")
  12.             Dim IPs As MatchCollection = reg.Matches(src)
  13.             Dim IPList As New List(Of String)
  14.             For Each Match In IPs
  15.                 IPList.Add(Match.ToString)
  16.             Next
  17.             IPList = IPList.Distinct.ToList
  18.             For Each item As String In IPList
  19.                 Dim col(1) As String
  20.                 col(0) = item
  21.                 col(1) = ""
  22.                 Dim lvi As ListViewItem = New ListViewItem(col)
  23.                 ListView1.Items.Add(lvi)
  24.  
  25.             Next
  26.         Catch ex As Exception
  27.             MessageBox.Show("Bạn Chưa Nhập Địa Chỉ Trang Web Cần Get IP", "Thông Báo")
  28.         End Try
  29.     End Sub
  30.  
  31.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  32.         ListView1.Columns.Add("IP", 100)
  33.         ListView1.Columns.Add("Status", 100)
  34.         ListView1.View = View.Details
  35.         ListView1.GridLines = True
  36.         ListView1.FullRowSelect = True
  37.     End Sub
  38.  
  39.     Sub CheckProxy(ByVal ProxyIP As String)
  40.         Try
  41.             Dim k As New WebProxy(ProxyIP)
  42.             k.BypassProxyOnLocal = True
  43.             Dim request As HttpWebRequest = CType(WebRequest.Create("http://www.ipchicken.com/"), HttpWebRequest)
  44.             request.Proxy = k
  45.             request.Timeout = 5000
  46.             Dim response As HttpWebResponse = request.GetResponse()
  47.             Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
  48.             Output("GOOD" & ":" & CurList.IndexOf(ProxyIP))
  49.         Catch ex As Exception
  50.             Output("BAD" & ":" & CurList.IndexOf(ProxyIP))
  51.         End Try
  52.     End Sub
  53.  
  54.     Sub Output(ByVal status As String)
  55.         If ListView1.InvokeRequired Then
  56.             ListView1.Invoke(New Action(Of String)(AddressOf Output), status)
  57.         Else
  58.             Dim int As Integer = status.Split(":").GetValue(1)
  59.             status = status.Split(":").GetValue(0)
  60.             ListView1.Items(int).SubItems(1).Text = status
  61.         End If
  62.     End Sub
  63.     Dim CurList As New List(Of String)
  64.     Private Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs)
  65.  
  66.  
  67.     End Sub
  68.     Private Sub ListView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
  69.         If e.Button = MouseButtons.Right Then
  70.             If ListView1.SelectedItems.Count > -1 Then
  71.                 ContextMenuStrip1.Show(MousePosition)
  72.             End If
  73.         End If
  74.     End Sub
  75.     Private Sub CHECKEDALLIPToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CHECKEDALLIPToolStripMenuItem.Click
  76.         CurList.Clear()
  77.         For Each item As ListViewItem In ListView1.Items
  78.             CurList.Add(item.SubItems(0).Text)
  79.             ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf CheckProxy), item.SubItems(0).Text)
  80.         Next
  81.     End Sub
  82.  
  83.     Private Sub CLEARBADIPToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CLEARBADIPToolStripMenuItem.Click
  84.         Dim goodlist As New List(Of ListViewItem)
  85.         For Each item As ListViewItem In ListView1.Items
  86.             If item.SubItems(1).Text = "GOOD" Then
  87.                 goodlist.Add(item)
  88.             End If
  89.         Next
  90.         ListView1.Items.Clear()
  91.  
  92.         For Each item In goodlist
  93.             ListView1.Items.Add(item)
  94.         Next
  95.     End Sub
  96.     '  Dim save As New IO.StreamWriter(ListView1)
  97.     Private saveip As String = Application.StartupPath & "\ip.txt"
  98.     Private Sub SAVELISTIPGOODToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SAVELISTIPGOODToolStripMenuItem.Click
  99.         Dim myWriter As New IO.StreamWriter(saveip)
  100.         For Each myItem As ListViewItem In ListView1.Items
  101.             myWriter.WriteLine(myItem.Text & "#" & myItem.SubItems(1).Text)
  102.         Next
  103.         myWriter.Close()
  104.     End Sub
  105. End Class
RAW Paste Data