简体   繁体   English

如何从IP地址知道地理位置

[英]How to know Geographic location from an IP address

I have created a login application in jsp/servlet in my web project and I want to know about the geographic locations of different users those access my login page. 我已经在Web项目的jsp / servlet中创建了一个登录应用程序,我想了解访问我的登录页面的不同用户的地理位置。 How can I know that a person is accessing my login page from where? 我怎么知道某个人正在从哪里访问我的登录页面? For example: If a person is accessing a page from Canada then a record will be inserted into my database such as : IP: 20.4.9.134 and location: Canada. 例如:如果某人正在访问加拿大的页面,那么一条记录将插入到我的数据库中,例如:IP:20.4.9.134和位置:Canada。

I use this: 我用这个:

http://freegeoip.net/xml/122.169.8.137 http://freegeoip.net/xml/122.169.8.137

Or 要么

http://www.geoplugin.net/xml.gp?ip=xx.xx.xx.xx http://www.geoplugin.net/xml.gp?ip=xx.xx.xx.xx

Easy call and it throws you an xml with everything you need to know 轻松调用,它会向您抛出一个xml,其中包含您需要了解的所有内容

Edit: New location for geoip 编辑:geoip的新位置

try a geo ip database, like maxmind 尝试地理IP数据库,例如maxmind

this question lists a few possibilities: Reputable geo-ip location Services 这个问题列出了几种可能性: 信誉良好的geo-ip位置服务

You can use the DB of MaxMind (the free version): http://www.maxmind.com/app/geolitecity 您可以使用MaxMind的DB(免费版): http : //www.maxmind.com/app/geolitecity

But have in mind that geolocating by IP is never too accurate and might give huge errors especially when using GPRS/EDGE/3G mobile internet. 但是请记住,通过IP进行地理位置定位永远不会太准确,并且可能会产生巨大的错误,尤其是在使用GPRS / EDGE / 3G移动互联网时。

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

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