Qua hình ảnh trên bản cảm thấy thế nào :D rất đơn giản phải không :D
Đây là toàn bộ mã nguồn của nó, mình chia sẽ cho mọi người có thể kiểm tra thoải mái :D
Imports System.Net
Imports System.Text.RegularExpressions
Imports System.Threading
Imports System.Windows.Forms
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim webc As New WebClient
webc.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0")
Dim src As String = webc.DownloadString(TextBox1.Text)
Dim reg As Regex = New Regex("[0-9]*?\.[0-9]*?\.[0-9]*?\.[0-9]+")
Dim IPs As MatchCollection = reg.Matches(src)
Dim IPList As New List(Of String)
For Each Match In IPs
IPList.Add(Match.ToString)
Next
IPList = IPList.Distinct.ToList
For Each item As String In IPList
Dim col(1) As String
col(0) = item
col(1) = ""
Dim lvi As ListViewItem = New ListViewItem(col)
ListView1.Items.Add(lvi)
Next
Catch ex As Exception
MessageBox.Show("Bạn Chưa Nhập Địa Chỉ Trang Web Cần Get IP", "Thông Báo")
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListView1.Columns.Add("IP", 100)
ListView1.Columns.Add("Status", 100)
ListView1.View = View.Details
ListView1.GridLines = True
ListView1.FullRowSelect = True
End Sub
Sub CheckProxy(ByVal ProxyIP As String)
Try
Dim k As New WebProxy(ProxyIP)
k.BypassProxyOnLocal = True
Dim request As HttpWebRequest = CType(WebRequest.Create("http://www.ipchicken.com/"), HttpWebRequest)
request.Proxy = k
request.Timeout = 5000
Dim response As HttpWebResponse = request.GetResponse()
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
Output("GOOD" & ":" & CurList.IndexOf(ProxyIP))
Catch ex As Exception
Output("BAD" & ":" & CurList.IndexOf(ProxyIP))
End Try
End Sub
Sub Output(ByVal status As String)
If ListView1.InvokeRequired Then
ListView1.Invoke(New Action(Of String)(AddressOf Output), status)
Else
Dim int As Integer = status.Split(":").GetValue(1)
status = status.Split(":").GetValue(0)
ListView1.Items(int).SubItems(1).Text = status
End If
End Sub
Dim CurList As New List(Of String)
Private Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Private Sub ListView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If e.Button = MouseButtons.Right Then
If ListView1.SelectedItems.Count > -1 Then
ContextMenuStrip1.Show(MousePosition)
End If
End If
End Sub
Private Sub CHECKEDALLIPToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CHECKEDALLIPToolStripMenuItem.Click
CurList.Clear()
For Each item As ListViewItem In ListView1.Items
CurList.Add(item.SubItems(0).Text)
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf CheckProxy), item.SubItems(0).Text)
Next
End Sub
Private Sub CLEARBADIPToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CLEARBADIPToolStripMenuItem.Click
Dim goodlist As New List(Of ListViewItem)
For Each item As ListViewItem In ListView1.Items
If item.SubItems(1).Text = "GOOD" Then
goodlist.Add(item)
End If
Next
ListView1.Items.Clear()
For Each item In goodlist
ListView1.Items.Add(item)
Next
End Sub
' Dim save As New IO.StreamWriter(ListView1)
Private saveip As String = Application.StartupPath & "\ip.txt"
Private Sub SAVELISTIPGOODToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SAVELISTIPGOODToolStripMenuItem.Click
Dim myWriter As New IO.StreamWriter(saveip)
For Each myItem As ListViewItem In ListView1.Items
myWriter.WriteLine(myItem.Text & "#" & myItem.SubItems(1).Text)
Next
myWriter.Close()
End Sub
End Class
VIDEO DEMO
Trong đoạn code các bạn chỉ cần thêm vào 1 textbox, 1 button, 1 listview, 1 StatusStrip1 thế là xong :D
Bạn nào cần test thử tools này thì để lại email mình send pass cho nhé. :D minh không chia sẽ vì có 1 số phần tử lợi dụng làm chuyện xấu.