How to determine nationality based on IP address?

删除回忆录丶 提交于 2020-01-16 19:32:13

问题


How can I tell the nationality of a user of my web site based on client ip?

Edit: Like commented, this question have been answered before:

https://stackoverflow.com/questions/283016/know-a-good-ip-address-geolocation-service


回答1:


use the GeoIP databse. there is a free one. there are also a lot of GeoIP webServices you can use.




回答2:


If you're thinking localization, let the user choose the correct language instead of doing it automatically -- or at least provide an easy way for them to change it and make it sticky via cookies. You can do ok most of the time at guessing using GeoIP, but sometimes you'll get it really wrong. Google sometimes sends my wife to the German version of their web site even though we're in the middle of the US. Using anonymization services (like TOR) will also likely result in guessing errors. Having the option to choose and keeping the choice on the computer will make it a better experience for your users.




回答3:


Besides the already mentioned GeoIP database, you could also use IP2LOCATION service. It's a paid one but it will also work.

Keep in mind that all these services will give you an estimate of the location but not a very accurate geographic position. I read a networking paper once stating that this is an impossible task to accomplish (give an accurate position of an IP address).



来源:https://stackoverflow.com/questions/585953/how-to-determine-nationality-based-on-ip-address

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!