I'm sure this didn't used to take as long, but for some reason this process currently takes between 15-30s, despite the fact that the webpage it is searching through loads instantly in IE7:
Dim IPAddress As String
Dim XMLReader As XmlTextReader = New XmlTextReader(" Dim WebClient As New WebClient
Dim WebStream As Stream
Dim WebStreamURLs As String() = {" " Dim StreamText As String
Dim StreamBuffer As Byte() = New Byte(256 - 1) {}
If XMLReader.CanResolveEntity Then
While XMLReader.ReadToFollowing("ip")
IPAddress = XMLReader.ReadElementString()
If IsValidIPAddress(IPAddress) Then Return IPAddress
End While
End If
For Each URL As String In WebStreamURLs
Try
WebStream = WebClient.OpenRead(URL)
If WebStream.CanRead Then
WebStream.Read(StreamBuffer, 0, 256)
StreamText = Encoding.ASCII.GetString(StreamBuffer, 0, 256)
Select Case URL
Case WebStreamURLs(0)
StreamText = StreamText.Substring((StreamText.IndexOf("<TITLE>") + 24), 15)
If (StreamText.IndexOf("<") <> (-1)) Then
StreamText = StreamText.Split("<")(0)
End If
Case WebStreamURLs(1)
StreamText = StreamText.Substring(0, StreamText.IndexOf(Chr(0)))
End Select
If IsValidIPAddress(StreamText) Then Return StreamText
End If
Catch Ex As Exception
Err.Clear()
End Try
Next
Lines in bold take 15-30s the first time the program is run. If you run the program shortly afterwards, it'll take <3s. Is there any reason why this seemingly simple and quick process would take so long?! I mean, the XML sites it's searching aren't exactly big!!
Any help appreciated!
Dim IPAddress As String
Dim XMLReader As XmlTextReader = New XmlTextReader(" Dim WebClient As New WebClient
Dim WebStream As Stream
Dim WebStreamURLs As String() = {" " Dim StreamText As String
Dim StreamBuffer As Byte() = New Byte(256 - 1) {}
If XMLReader.CanResolveEntity Then
While XMLReader.ReadToFollowing("ip")
IPAddress = XMLReader.ReadElementString()
If IsValidIPAddress(IPAddress) Then Return IPAddress
End While
End If
For Each URL As String In WebStreamURLs
Try
WebStream = WebClient.OpenRead(URL)
If WebStream.CanRead Then
WebStream.Read(StreamBuffer, 0, 256)
StreamText = Encoding.ASCII.GetString(StreamBuffer, 0, 256)
Select Case URL
Case WebStreamURLs(0)
StreamText = StreamText.Substring((StreamText.IndexOf("<TITLE>") + 24), 15)
If (StreamText.IndexOf("<") <> (-1)) Then
StreamText = StreamText.Split("<")(0)
End If
Case WebStreamURLs(1)
StreamText = StreamText.Substring(0, StreamText.IndexOf(Chr(0)))
End Select
If IsValidIPAddress(StreamText) Then Return StreamText
End If
Catch Ex As Exception
Err.Clear()
End Try
Next
Lines in bold take 15-30s the first time the program is run. If you run the program shortly afterwards, it'll take <3s. Is there any reason why this seemingly simple and quick process would take so long?! I mean, the XML sites it's searching aren't exactly big!!
Any help appreciated!