IP良好的地理位置API [英] Good Geolocation API by IP

查看:118
本文介绍了IP良好的地理位置API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个好的免费API,至少可以让我知道IP的国家。
我发现了其中的一些可以工作,但他们似乎不可靠。
主要的问题是我必须在一天内提出约50000-100000个请求。



是否有一些好的脚本可以安装在我的服务器上用它来代替API?
Thank you

解决方案

您可以尝试使用 IPInfoDB ,因为我发现它很有用。


API返回IP地址(国家,地区,城市,
邮编,纬度,经度)以及XML
格式的关联时区。您可以使用PHP,Javascript,Ruby,
Python和ASP查找以下代码示例。 $ b


是否有一些好的脚本可以安装在我的服务器上,并使用
而不是API?


来自同一网站的ASP示例

 <%
'获取访问者IP
Dim UserIPAddress
UserIPAddress = Request.ServerVariables(HTTP_X_FORWARDED_FOR)
如果UserIPAddress =则
UserIPAddress = Request.ServerVariables(REMOTE_ADDR)
结束如果
%>
<%
'设置API密钥
api_key =< your_api_key>
%>
<%
'获取信息并打印
myxml =http://api.ipinfodb.com/v3/ip-city/?key=& api_key&& ip =& UserIPAddress&& format = xml
set xml = server.CreateObject(MSXML2.DOMDocument.6.0)
xml.async =false
xml。 resolveExternals =false
xml.setPropertyServerHTTPRequest,true
xml.load(myxml)
response.write< p>< strong>第一结果< / strong>< br />
for i = 0 to 10
response.write xml.documentElement.childNodes(i).nodename& :
response.write xml.documentElement.childNodes(i).text& <峰; br /> 中
NEXT
response.write< / p>
%>

同时查看 Maxmind

I am looking for a good free API that will return me at least the country of the IP. I found a couple of that will work but they seems to be unreliable. The main problem is that I have to make about 50000-100000 requests for a day.

Is there some good script that I can install on my server and use it instead of API? Thank you

解决方案

You may try to use IPInfoDB as I found it useful.

The API returns the location of an IP address (country, region, city, zipcode, latitude, longitude) and the associated timezone in XML format. You can find below code samples with PHP, Javascript, Ruby, Python and ASP.


Is there some good script that I can install on my server and use it instead of API?

ASP example from the same site

<%
    'Get visitor IP
    Dim UserIPAddress
    UserIPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
    If UserIPAddress = "" Then
     UserIPAddress = Request.ServerVariables("REMOTE_ADDR")
    End If
%>
<%
    'Set API key
    api_key = "<your_api_key>"
%>
<%
    'Get info and print
    myxml="http://api.ipinfodb.com/v3/ip-city/?key="&api_key&"&ip=" &UserIPAddress&"&format=xml"
    set xml = server.CreateObject("MSXML2.DOMDocument.6.0")
    xml.async = "false"
    xml.resolveExternals = "false"
    xml.setProperty "ServerHTTPRequest", true
    xml.load(myxml)
    response.write "<p><strong>First result</strong><br />"
    for i=0 to 10
        response.write xml.documentElement.childNodes(i).nodename & "  :  "
        response.write xml.documentElement.childNodes(i).text & "<br/>"
    NEXT
    response.write "</p>"
%> 

Also check out Maxmind

这篇关于IP良好的地理位置API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆