0
我想從IP地址獲取國家位置,我也從實際的URL查找。然而,對於某些URL我收到以下錯誤:從網址獲取IP地址
The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for
我想用下面的代碼來識別可能的代理,但因爲這是一個普通的控制檯應用程序,我不知道怎麼去解決它。這是我的代碼;
For Each prod In querylist
If myfetcher.getHtml(prod, userAgent, page) Then
' The lines below I use to find proxy ip
' but error name 'Request' not declared
' Dim nowip As String
' nowip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
' If nowip = "" Then
'nowip = Request.ServerVariables("REMOTE_ADDR")
'End If
'
If prod.Contains("http://") Then
prod = Regex.Replace(prod, "http://", "")
End If
badHost = prod
Dim ipEntry As IPHostEntry = Dns.GetHostByName(prod)
Dim IPAdd As IPAddress() = ipEntry.AddressList
Dim i As Integer = 0
For i = 0 To IPAdd.GetUpperBound(0)
number = number & "IP Address {0}:{1}" & IPAdd(i).ToString
Next
IPList.Add(prod & " " & number)
number = ""
Else
badList.Add(prod)
number = ""
End If
count = count + 1
Next
你正在剝離URL而不是頁面路徑的http - 你是否將'stackoverflow.com/questions/3813747 /'傳遞給DNS調用?你只需要'stackoverflow.com'部分。您可以使用System.Uri類從URL解析域。 – Rup 2010-09-28 14:30:00
這是給出錯誤www.edresearch.co.jp, – vbNewbie 2010-09-28 14:40:36
的URL的例子,所以我想你說www。不應該在那裏,其他的網址就像hhhh.com.cn,所以我刪除了.com部分,這有幫助。謝謝你的幫助。 – vbNewbie 2010-09-28 14:42:25