digitaldrew
Well-known member
- Joined
- Nov 10, 2012
- Messages
- 167
- Programming Experience
- Beginner
Hey everyone..I am trying to use a regular expression so I can pull all IPort off a specific page and add them to a listbox, but nothing seams to be happening.
Any idea where I am going wrong here?
Any idea where I am going wrong here?
VB.NET:
Private Sub btnSourceA_Click(sender As System.Object, e As System.EventArgs) Handles btnSourceA.Click
Dim request As HttpWebRequest = Nothing
Dim response As HttpWebResponse = Nothing
Try
request = DirectCast(WebRequest.Create(("http://nntime.com/proxy-list-01.htm")), HttpWebRequest)
request.Accept = "*/*"
request.Method = "GET"
request.Timeout = &H2710
request.ReadWriteTimeout = &H2710
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
response = DirectCast(request.GetResponse, HttpWebResponse)
Dim input As String = New StreamReader(response.GetResponseStream).ReadToEnd
Dim regex2 As New Regex("\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b\:(\d+)", RegexOptions.Multiline)
For Each match2 As Match In regex2.Matches(input)
Dim output As String = ""
output &= match2.Groups.Item(1).Value.Trim & "."
output &= match2.Groups.Item(2).Value.Trim & "."
output &= match2.Groups.Item(3).Value.Trim & "."
output &= match2.Groups.Item(4).Value.Trim & ":"
output &= match2.Groups.Item(5).Value.Trim
lstProxiesToTest.Items.Add(output)
Next
Catch exception As Exception
Trace.WriteLine(("Get Views ex: " & exception.Message))
Finally
If (Not response Is Nothing) Then
response.Close()
End If
End Try
MsgBox("Completed!")
End Sub