Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Text.RegularExpressions
- Public Class Form1
- Dim Thread1 As System.Threading.Thread
- Private Sub GrabProxies()
- CheckForIllegalCrossThreadCalls = False
- Dim i As Integer = 1
- Do Until i = NumericUpDown1.Value + 1
- Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://hidemyass.com/proxy-list/" + i.ToString)
- Dim response As System.Net.HttpWebResponse = request.GetResponse
- Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
- Dim rssourcecode As String = sr.ReadToEnd
- Dim r As New System.Text.RegularExpressions.Regex("(\d{1,4}\.\d{1,4}\.\d{1,4}\.\d{1,4})</span></td>\D+(\d{1,5})</td>\D+<img src=""\S+""\D+""flag"" /> (\w+)\D+\S+\D+(\d+%)\D+\S+\D+(\d+%)""\D+<td>(\w+)\D+"">(\w+)")
- Dim matches As MatchCollection = r.Matches(rssourcecode)
- For Each itemcode As Match In matches
- With ListView1.Items.Add("")
- .SubItems.Add(itemcode.Groups(1).Value)
- .SubItems.Add(itemcode.Groups(2).Value)
- .SubItems.Add(itemcode.Groups(3).Value)
- .SubItems.Add(itemcode.Groups(4).Value)
- .SubItems.Add(itemcode.Groups(5).Value)
- .SubItems.Add(itemcode.Groups(6).Value)
- .SubItems.Add(itemcode.Groups(7).Value)
- End With
- Next
- i = i + 1
- Loop
- End Sub
- Private Sub ListView1_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles ListView1.ColumnClick
- '// check if it contains items.
- If Not ListView1.Items.Count = 0 Then lvColumnSort(e.Column, ListView1) '// send Column Index and the ListView used.
- End Sub
- #Region "================= SORT LISTVIEW COLUMNS BY SELECTED COLUMN ================="
- Private arlSortLvItems As New ArrayList '// adds ListView items to.
- Private bSortDescending As Boolean = True '// Toggles if .Ascending or Descending.
- Private Sub lvColumnSort(ByVal columnIndex As Integer, ByVal selectedListView As ListView)
- With selectedListView
- arlSortLvItems.Clear() '// clear ArrayList for new input.
- For Each itm As ListViewItem In .Items '// loop thru ListView.Items
- Select Case columnIndex '// check which column is clicked and add items to ArrayList as needed, first item will be the .Sorting item.
- Case 0 '// IpAdress, Port, Country, Speed.
- arlSortLvItems.Add(itm.Text & "~" & itm.SubItems(1).Text & "~" & itm.SubItems(2).Text & "~" & itm.SubItems(3).Text & "~" & itm.SubItems(4).Text)
- Case 1 '// Port, IpAdress, Country, Speed.
- arlSortLvItems.Add(itm.SubItems(1).Text & "~" & itm.Text & "~" & itm.SubItems(2).Text & "~" & itm.SubItems(3).Text & "~" & itm.SubItems(4).Text)
- Case 2 '// Country, Speed, IpAdress, Port.
- arlSortLvItems.Add(itm.SubItems(2).Text & "~" & itm.SubItems(4).Text & "~" & itm.SubItems(3).Text & "~" & itm.Text & "~" & itm.SubItems(1).Text)
- Case 3 '// Speed, Country, IpAdress, Port.
- arlSortLvItems.Add(itm.SubItems(4).Text & "~" & itm.SubItems(3).Text & "~" & itm.SubItems(2).Text & "~" & itm.Text & "~" & itm.SubItems(1).Text)
- End Select
- Next
- arlSortLvItems.Sort() '// sort ArrayList.
- .Items.Clear() '// clear ListView to add Sorted items back.
- getSortOrderOfItems(columnIndex, selectedListView, bSortDescending) '// determines if needed to add .Ascending or .Descending.
- bSortDescending = Not bSortDescending '// Toggle True/False for next click.
- End With
- End Sub
- Private Sub getSortOrderOfItems(ByVal columnIndex As Integer, ByVal selectedListView As ListView, ByVal isDescending As Boolean)
- With selectedListView
- .Sorting = SortOrder.None '// No Sort order.
- If isDescending Then
- For Each itm As String In arlSortLvItems '// loop thru items in ArrayList.
- setItemsBackToListView(columnIndex, selectedListView, itm.Split("~"c)) '// .Split to get values as arrays.
- Next
- Else
- For i As Integer = arlSortLvItems.Count - 1 To 0 Step -1 '// loop backwards thru items ArrayList.
- setItemsBackToListView(columnIndex, selectedListView, arlSortLvItems(i).ToString.Split("~"c)) '// .Split to get values as arrays.
- Next
- End If
- End With
- End Sub
- Private Sub setItemsBackToListView(ByVal columnIndex As Integer, ByVal selectedListView As ListView, ByVal ArrayListItem() As String)
- With selectedListView
- Dim lvItem As New ListViewItem '// new ListView Item.
- With lvItem
- Select Case columnIndex
- Case 0 '// IpAdress, Port, Country, Speed.
- .Text = ArrayListItem(0) '// IpAdress.
- .SubItems.Add(ArrayListItem(1)) '// Port.
- .SubItems.Add(ArrayListItem(2)) '// Country.
- .SubItems.Add(ArrayListItem(3)) '// Speed.
- Case 1 '// Port, IpAdress, Country, Speed.
- .Text = ArrayListItem(1) '// IpAdress.
- .SubItems.Add(ArrayListItem(0)) '// Port.
- .SubItems.Add(ArrayListItem(2)) '// Country.
- .SubItems.Add(ArrayListItem(3)) '// Speed.
- Case 2 '// Country, Speed, IpAdress, Port.
- .Text = ArrayListItem(2) '// IpAdress.
- .SubItems.Add(ArrayListItem(3)) '// Port.
- .SubItems.Add(ArrayListItem(0)) '// Country.
- .SubItems.Add(ArrayListItem(1)) '// Speed.
- Case 3 '// Speed, Country, IpAdress, Port.
- .Text = ArrayListItem(2) '// IpAdress.
- .SubItems.Add(ArrayListItem(3)) '// Port.
- .SubItems.Add(ArrayListItem(1)) '// Country.
- .SubItems.Add(ArrayListItem(0)) '// Speed.
- End Select
- End With
- .Items.Add(lvItem) '// add item back to ListView.
- End With
- End Sub
- #End Region
- Private Sub SaveFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
- Dim myFile As String = SaveFileDialog1.FileName
- Dim myWriter As New IO.StreamWriter(myFile)
- For Each myItem As ListViewItem In ListView1.Items
- If CheckBox1.Checked = True Then
- myWriter.WriteLine(myItem.Text & myItem.SubItems(1).Text & ":" & myItem.SubItems(2).Text)
- Else
- myWriter.WriteLine(myItem.Text & myItem.SubItems(1).Text & " | " & myItem.SubItems(2).Text & " | " & myItem.SubItems(3).Text & " | " & myItem.SubItems(4).Text & " | " & myItem.SubItems(5).Text & " | " & myItem.SubItems(6).Text & " | " & myItem.SubItems(7).Text)
- End If
- Next
- myWriter.Close()
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Thread1 = New System.Threading.Thread(AddressOf GrabProxies)
- Thread1.Start()
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- SaveFileDialog1.ShowDialog()
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- ListView1.Items.Clear()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement