首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >获取有关IP地址的数据

获取有关IP地址的数据
EN

Stack Overflow用户
提问于 2012-08-17 15:18:01
回答 2查看 2K关注 0票数 1

我在一个IPv4数据库中有大约30K的IP地址( MySQL )。

我想得到与这些IP相关的信息,比如

乡村城市等。

我已经尝试过IP到国家的数据库,这些数据库不太准确,而且对许多IP来说是错误的。

Web不允许这些大量的IP查询,也可能不准确。

我想要准确的信息。(至少国家应该准确)

后端有Java,PHP/HTML5 5显示

请帮帮忙。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-08-17 15:19:57

我认为maxmind可能是事实上的geoip数据库。他们的提供免费的在国家一级为99.5%,在城市一级为78%。

它们同时具有php和java库。http://www.maxmind.com/app/ip-location

票数 3
EN

Stack Overflow用户

发布于 2012-08-17 15:30:50

试试这个,它的工作方式类似于magic...........

密钥与秘密:

代码语言:javascript
复制
private final String key = "86b780aec0cee918718d7eb2fa084df412771c17";
private final String secret = "d3e3fa0a1fc6a35ac02aa591ed32ecaa750df9a7";

创建会话的方法:

代码语言:javascript
复制
public void xmlCreateSession(){

             String createSession = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+"\n"+"<request>"+"\n"+"<token>"+"</token>"+"\n"+"<key>"+this.getKey()+"</key>"+"\n"+"<secret>"+this.getSecret()+"</secret>"+"\n"+"</request>";
            firingUrl = "https://int.yumzing.com/index.php?func=sessionCreate";
            // firingUrl = "http://199.87.235.147/sessionCreate";

          //firingUrl = "https://int.yumzing.com/sessionCreate";

             String tempCreate = postData(firingUrl, createSession);
             this.getMToken(tempCreate);
             System.out.println("getToken value "+this.getToken()); 

    }

查找IP:的方法

代码语言:javascript
复制
public void xmlUserIp(){

           String userIp = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+"\n"+"<request>"+"\n"+"<token>"+this.getToken()+"</token>"+"\n"+"</request>";

           firingUrl = "https://int.yumzing.com/index.php?func=userIp";

           String tempIp = postData(firingUrl, userIp);
           this.getMIp(tempIp);
           System.out.println("getToken value "+this.getIp()); 

    }

基于IP:的信息获取的方法

代码语言:javascript
复制
public void xmlUserLocation(){

        this.xmlUserIp();
        System.out.println("With in xmlUserLocation-"+this.getToken()+" "+this.getIp());

           String userLocation = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+"\n"+"<request>"+"\n"+"<token>"+this.getToken()+"</token>"+"\n"+"<ip>"+this.getIp()+"</ip>"+"\n"+"</request>";
           firingUrl = "https://int.yumzing.com/?func=userLocation";



          System.out.println("With in xmlUserLocation-"+this.getToken()+" "+this.getIp());
           String tempLoc = postData(firingUrl, userLocation);
           System.out.println("In xmluserLoc"+tempLoc);
           this.getMLocation(tempLoc);

           System.out.println("getToken value "+this.getCountry()); 
           System.out.println("getToken value "+this.getState()); 
           System.out.println("getToken value "+this.getCity()); 
           System.out.println("getToken value "+this.getLatitude()); 
           System.out.println("getToken value "+this.getLongitude()); 
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12008538

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档