从ASP.NET页面我能够检索客户端的IP地址(至少是明显的IP地址). 我想知道是否有一个免费服务,我可以从代码隐藏中访问,当用IP查询时,它将返回国家(不需要城市). 我无法处理基于Web http的
我想知道是否有一个免费服务,我可以从代码隐藏中访问,当用IP查询时,它将返回国家(不需要城市).
我无法处理基于Web http的服务,你必须手动输入IP,我每天都有成千上万的访问量!
任何线索欢迎.
是的, Check It Out!祝好运!
编辑:由于你没有指定一种语言我继续创建我自己的密钥用于测试目的,并制作了这个小样本.这将获得任何给定IP地址的国家/地区.祝好运.
Try Dim webClient As WebClient = New WebClient 'I am at work so i need a proxy authentication 'webClient.Proxy.Credentials = New NetworkCredential("username", "password") Dim stream As Stream = webClient.OpenRead("http://api.ipinfodb.com/v3/ip-country/?key=<key here>&ip=" & Context.Request.ServerVariables("REMOTE_ADDR")) Dim sReader As New StreamReader(stream) Dim content As String = sReader.ReadToEnd() Response.Write(content.Split(";")(4)) Catch ex As Exception Response.Write("Error occured") End Try