Let's start ,
First go ahead and create a new project and we need a ListBox and Three Buttons so just add them . After adding them to your form arrange as you see in the below picture.
Now coming to the coding point , first add Imports System.Text.RegularExpressions namespace because we use regex as i said before , first open the button click event which is the grab button and add this codes.
'creating our httpwebrequest target NOTE: you can use any websites that use to provide proxies directly Dim the_request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://proxy-ip-list.com") 'creating the httpwebresponce Dim the_response As System.Net.HttpWebResponse = the_request.GetResponse 'defining the stream reader to read the data from the httpwebresponse Dim stream_reader As System.IO.StreamReader = New System.IO.StreamReader(the_response.GetResponseStream()) 'defining a string to stream reader fisnished streaming Dim code As String = stream_reader.ReadToEnd 'haha here we use the regex Dim expression As New System.Text.RegularExpressions.Regex("[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}:[0-9]{1,4}") 'adding the proxies to the listbox Dim mtac As MatchCollection = expression.Matches(code) For Each itemcode As Match In mtac ListBox1.Items.Add(itemcode) NextAfter the first button we will see the second button which save.
If ListBox1.Items.Count = (0) Then MessageBox.Show("Please click grab to grab proxies and then try saving", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Else 'defining a streamwriter Dim S_W As IO.StreamWriter 'converting listbox items to string Dim itms() As String = {ListBox1.Items.ToString} ''defining a savefiledialog Dim save As New SaveFileDialog Dim it As Integer save.FileName = "Grabbed Proxies" save.Filter = "Grabbed Proxies (*.txt)|*.txt|ALL Files (*.*)|*.*" save.CheckPathExists = True save.ShowDialog(Me) S_W = New IO.StreamWriter(save.FileName) For it = 0 To ListBox1.Items.Count - 1 S_W.WriteLine(ListBox1.Items.Item(it)) Next S_W.Close() End IfAt last we need to add a line of code to clear the listbox which is
ListBox1.Items.Clear()
Finally debug your program and test test ..
YAY it's working ,I have explained the code by commenting over the codes and i hope this is helpful . thanks
6 comments
Working Working
ReplyGreat tutorial! keep on..
ReplyHello what if i want to grab fresh proxies from a blog or a website where they update fresh proxies daily to mah tool?
Replyit's possible as long as you use the right regular expressions
Replywould be cool to show how to get more then just the proxies on the first page as thats not enough to do much with , but nice basic example
ReplyPost a Comment
Note: Only a member of this blog may post a comment.