我在一个IPv4数据库中有大约30K的IP地址( MySQL )。
我想得到与这些IP相关的信息,比如
乡村城市等。
我已经尝试过IP到国家的数据库,这些数据库不太准确,而且对许多IP来说是错误的。
Web不允许这些大量的IP查询,也可能不准确。
我想要准确的信息。(至少国家应该准确)
后端有Java,PHP/HTML5 5显示
请帮帮忙。
发布于 2012-08-17 15:19:57
我认为maxmind可能是事实上的geoip数据库。他们的提供免费的在国家一级为99.5%,在城市一级为78%。
它们同时具有php和java库。http://www.maxmind.com/app/ip-location
发布于 2012-08-17 15:30:50
试试这个,它的工作方式类似于magic...........
密钥与秘密:
private final String key = "86b780aec0cee918718d7eb2fa084df412771c17";
private final String secret = "d3e3fa0a1fc6a35ac02aa591ed32ecaa750df9a7";创建会话的方法:
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:的方法
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:的信息获取的方法
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());
}https://stackoverflow.com/questions/12008538
复制相似问题