Reputation: 59
Public Function GetIPInfo(ByVal IPNumb As String, ByVal GetInfo As String) As String
Dim i1, i2 As Integer
Dim s1, s2, s3 As String
Dim IPCheckWebsite As String
Dim WC As System.Net.WebClient = New System.Net.WebClient()
IPCheckWebsite = WC.DownloadString("http://whatismyipaddress.com/ip/" & IPNumb)
For i1 = 1 To Len(IPCheckWebsite)
s1 = Mid(IPCheckWebsite, 1, i1)
If InStr(s1, GetInfo) > 0 Then
s2 = Mid(IPCheckWebsite, i1 + 10)
For i2 = 1 To Len(s2)
s3 = Mid(s2, 1, i2)
If InStr(s3, "<") > 0 Then
IPCheckWebsite = Mid(s3, 1, i2 - 1)
GoTo Done
End If
Next
End If
Next
Done: Return IPCheckWebsite End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Clear()
ListBox1.Items.Add("IP: " & GetIPInfo(TextBox3.Text, "IP:"))
ListBox1.Items.Add("Hostname: " & GetIPInfo(TextBox3.Text, "Hostname:"))
ListBox1.Items.Add("ISP: " & GetIPInfo(TextBox3.Text, "ISP:"))
ListBox1.Items.Add("Organization: " & GetIPInfo(TextBox3.Text, "Organization:"))
ListBox1.Items.Add("Services: " & GetIPInfo(TextBox3.Text, "Services:"))
ListBox1.Items.Add("Country: " & GetIPInfo(TextBox3.Text, "Country:"))
ListBox1.Items.Add("State/Region: " & GetIPInfo(TextBox3.Text, "State/Region:"))
ListBox1.Items.Add("City: " & GetIPInfo(TextBox3.Text, "City:"))
End Sub
It says the website server has a 503 Error, But the site is up and works fine. Am I Doing Something Wrong?
Dim WC As System.Net.WebClient = New System.Net.WebClient()
IPCheckWebsite = WC.DownloadString("http://whatismyipaddress.com/ip/" & IPNumb)
specifically This code
Upvotes: 1
Views: 418
Reputation: 117333
My guess is that whatismyipaddress.com probably has measures in place to try and block people from doing precisely what you are doing.
They are returning a 503 response which means "service unavailable".
If you are sure that you should be able to scrape their site with a bot, you'll need to contact the administrator of whatismyaddress.com for their help.
Another issue with your code is that it appears you are fetching their page 8 times for one button click, which is probably not good etiquette (unless you know that WC.DownloadString is caching the response, I guess).
Upvotes: 1