Visual Basic:Hidemyass正则表达式 - 我完全迷失了

时间:2014-03-11 17:39:51

标签: vb.net

我完全失去了家伙。我是Regex的新手,几天后我才意识到我讨厌它。有人可能会帮忙吗?我试图制作一个代理抓取工具,从this proxy list抓取代理并继续刮擦,直到没有更多的代理。有人可以帮我解释我的代码出错的地方吗?或者帮我找到一个更容易正则表达式的更好的代理网站?谢谢!

版本:VB2012

导入System.Text.RegularExpressions 公共类代理

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    Dim the_request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://gatherproxy.com/proxylist/port/8080")
    Dim the_response As System.Net.HttpWebResponse = the_request.GetResponse
    Dim stream_reader As System.IO.StreamReader = New System.IO.StreamReader(the_response.GetResponseStream())
    Dim code As String = stream_reader.ReadToEnd
    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}")
    Dim mtac As MatchCollection = expression.Matches(code)
    For Each itemcode As Match In mtac
        ListBox1.Items.Add(itemcode)
    Next
End Sub

Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
    If ListBox1.Items.Count = (0) Then
        MessageBox.Show("Please click start to grab proxies!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    Else
        Dim S_W As IO.StreamWriter
        Dim itms() As String = {ListBox1.Items.ToString}
        Dim save As New SaveFileDialog
        Dim it As Integer
        save.FileName = "Fresh Proxies"
        save.Filter = "Fresh 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 If
End Sub

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
    ListBox1.Items.Clear()
End Sub

Private Sub proxy_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub

结束班

1 个答案:

答案 0 :(得分:-1)

你的正则表达式很好,但HideMyAss代理是从代理解析器“隐藏”的。

如果您从HideMyAss代理检查HTML代码,您将找出我想说的内容。