简体   繁体   English

获取网页访问者的IP,ISP和地理位置

[英]Get IP, ISP and GeoLocation of a webpage visitor

Is there any way to get the ISP and GeoLocation for a user that access a website in Java? 是否可以通过Java获取访问网站的用户的ISP和GeoLocation?

Getting the IP is easy. 获取IP很容易。 It's request.getRemoteAddr() . 这是request.getRemoteAddr() Any hints on getting the ISP and location? 有关获取ISP和位置的任何提示? Are there any API's or libraries available? 是否有可用的API或库? I'm guessing that you have to map all the IPs to ISPs. 我猜您必须将所有IP映射到ISP。 Any ideas? 有任何想法吗?

There is no ready solution in Java. Java中没有现成的解决方案。 In general there is only one method to do it - you should use whois protocol to access data about host's ip from Regional Internet Register (RIR), for example from http://www.db.ripe.net/whois . 通常,只有一种方法可以执行此操作-您应该使用whois协议从区域Internet注册(RIR),例如从http://www.db.ripe.net/whois访问有关主机ip的数据。 Other solutions in the Internet will more or less depend on RIRs + some algorithm to process data. 互联网中的其他解决方案或多或少将取决于RIR +一些算法来处理数据。

There is a possibility to use telnet to connect to RIPE or copy a snapshot of database onto your server. 可以使用telnet连接到RIPE或将数据库快照复制到服务器上。

The only problem is that the output from whois is not very convenient to process. 唯一的问题是whois的输出处理起来不是很方便。 Everything depends on your application and required accuracy. 一切都取决于您的应用程序和所需的准确性。

Try with MaxMind GeoIp Java API. 尝试使用MaxMind GeoIp Java API。 The more complete and accurate IP database is commercial, but they have a free Country and City "light" database. 更加完整和准确的IP数据库是商业数据库,但是它们具有免费的Country and City“轻型”数据库。

http://www.maxmind.com/app/java http://www.maxmind.com/app/java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM