使用经典 ASP 3.0 获取访问者国家/地区信息
我需要使用经典 asp 3.0 获取访问者国家/地区信息,我使用下面的代码,但它返回我 XX 而不是国家/地区名称。对此有任何建议/帮助。
<%
URL = "http://api.hostip.info/country.php?ip=" & Request.ServerVariables("REMOTE_ADDR")
Set conn = Server.CreateObject("MSXML2.ServerXMLHTTP")
conn.open "GET", URL, False, "", ""
conn.send
UserCountry = conn.ResponseText
Response.Write(UserCountry)
%>
我还设置了一个包含上述代码的查看页面。
http://www.datingmaze.co.uk/rac.asp
如果我尝试< a href="http://api.hostip.info/country.php?ip=12.215.42.19" rel="nofollow">http://api.hostip.info/country.php?ip=12.215.42.19< /a> 它给了我正确的输出,但如果我尝试 http://api. hostip.info/country.php?ip=119.152.136.247 给我错误的输出,即 XX,尽管我提供了正确的 IP 地址。
提前致谢。
I need to get visitors country information using classic asp 3.0, i'm using below code but it returns me XX instead of country name. any suggestions/help on this.
<%
URL = "http://api.hostip.info/country.php?ip=" & Request.ServerVariables("REMOTE_ADDR")
Set conn = Server.CreateObject("MSXML2.ServerXMLHTTP")
conn.open "GET", URL, False, "", ""
conn.send
UserCountry = conn.ResponseText
Response.Write(UserCountry)
%>
i have also setup a page for view which contains the above code.
http://www.datingmaze.co.uk/rac.asp
If i try http://api.hostip.info/country.php?ip=12.215.42.19 it gives me correct output, but if i tried http://api.hostip.info/country.php?ip=119.152.136.247 gives me wrong output i.e. XX although i provided the correct IP address.
thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 GeoIP 来实现此目的。
他们有一个免费的 COM API,您可以使用:
http://www.maxmind.com/app/com< /a>
http://www.maxmind.com/GeoIP-COM-1.3.zip< /a>
他们的 COM API 公开了以下内容:
查找后您将收到的数据:
因此,您将使用 find_by_addr,而不是使用 find_by_name。这将根据 IPv4 地址查找国家/地区。
这是一个更好的解决方案,因为依赖远程第三方提供商可能存在风险。他们的网站可能会崩溃、负载过重等。
您可以在此处下载其 IP/国家/地区数据库的免费版本:
http://www.maxmind.com/app/geolitecountry
You can use GeoIP for this.
They have a free COM API which you can use:
http://www.maxmind.com/app/com
http://www.maxmind.com/GeoIP-COM-1.3.zip
Their COM API exposes the following:
The data that you would receive after lookup:
So instead of the using find_by_name, you would use find_by_addr. Which would lookup the country based on an IPv4-address.
This is a better solution since relying on remote 3rd party providers can be risky. Their site might go down, be under heavy load, etc.
You can download the free version of their IP/Country database here:
http://www.maxmind.com/app/geolitecountry