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