Regex for website

Daivd5465

Lurker
Member
Joined
Threads
24
Posts
56
Hello,
Does anybody have regex to extract proxy from this site? -
I try
Code:
        Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("https://free-proxy-list.net/")
        Dim response As System.Net.HttpWebResponse = request.GetResponse
        Dim reader As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream)
        Dim readcode As String = reader.ReadToEnd
        Dim checker As New System.Text.RegularExpressions.Regex("<td>(.*?)</td><td>(.*?)</td>")
        Dim right As MatchCollection = checker.Matches(readcode)
        For Each itemcode As Match In right
            ListBox1.Items.Add(itemcode)
        Next
But result is only:
Code:
<td>170.84.60.4</td><td>8080</td>
<td>BR</td><td-class='hm'>Brazil</td><td>anonymous</td>
<td>202.137.4.189</td><td>443</td>
<td>ID</td><td-class='hm'>Indonesia</td><td>anonymous</td>
<td>167.114.150.82</td><td>8080</td>
<td>CA</td><td-class='hm'>Canada</td><td>anonymous</td>
<td>23.239.9.177</td><td>8888</td>
<td>US</td><td-class='hm'>United-States</td><td>elite-proxy</td>
<td>178.206.212.121</td><td>8080</td>

I want extract proxies in IP:PORT format if possible.
 
  • Daivd5465
    Created
  • Last reply
  • 4
    Replies
  • 1K
    Views
  • 2
    Participants
  • Participants list
Code:
Dim regexResult As MatchCollection =
Regex.Matches(readcode, "(?<=<tr><td>)(((\d{1,3})(\.))((\d{1,3})(\.))((\d{1,3})(\.))((\d{1,3})))(</td><td>)(\d{2,5})")
        Dim lstProxies As New List(Of String)
        For Each strProxy As Match In regexResult
            If strProxy.Value.Contains("</td><td>") Then
                lstProxies.Add((strProxy.Value.Replace("</td><td>", "")).Trim())
            End If
        Next
        ListBox1.Items.AddRange(lstProxies.Distinct().ToArray())
        MsgBox("Found x" & ListBox1.Items.Count & " Proxies.", MsgBoxStyle.Information, "Info")
 
  • Thread Starter Thread Starter
  • #3
@MR.ViPeR Thanks, but I don't know where to insert your code to mine. Could you help me more please? :)
 
@MR.ViPeR Thanks, but I don't know where to insert your code to mine. Could you help me more please? :)
i have just the codes that you posted, so by them:
Code:
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("https://free-proxy-list.net/")
        Dim response As System.Net.HttpWebResponse = request.GetResponse
        Dim reader As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream)
        Dim readcode As String = reader.ReadToEnd
        Dim regexResult As MatchCollection =
Regex.Matches(readcode, "(?<=<tr><td>)(((\d{1,3})(\.))((\d{1,3})(\.))((\d{1,3})(\.))((\d{1,3})))(</td><td>)(\d{2,5})")
       Dim lstProxies As New List(Of String)
       For Each strProxy As Match In regexResult
           If strProxy.Value.Contains("</td><td>") Then
               lstProxies.Add((strProxy.Value.Replace("</td><td>", "")).Trim())
           End If
       Next
       ListBox1.Items.AddRange(lstProxies.Distinct().ToArray())