简体   繁体   中英

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?

Getting the IP is easy. It's request.getRemoteAddr() . Any hints on getting the ISP and location? Are there any API's or libraries available? I'm guessing that you have to map all the IPs to ISPs. Any ideas?

There is no ready solution in 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 . Other solutions in the Internet will more or less depend on RIRs + some algorithm to process data.

There is a possibility to use telnet to connect to RIPE or copy a snapshot of database onto your server.

The only problem is that the output from whois is not very convenient to process. Everything depends on your application and required accuracy.

Try with MaxMind GeoIp Java API. The more complete and accurate IP database is commercial, but they have a free Country and City "light" database.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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