如何检测访问者的国家/地区?
可能的重复:
IP 地址的位置检测技术
对于我们的网站来说,准确了解来自哪个 IP 地址非常重要我们的访客来自哪个国家。
我想我的问题的最佳答案是当前浏览器系统的简单地理位置功能,它只是询问用户是否允许网站查看他的地理位置:http://dev.w3.org/geo/api/spec-source.html
但我不想打扰访客带着问题,我希望自动检测访问者的位置(国家/地区就足够了)。
执行此操作的最佳方法是什么? - 哪个 IP 数据库最好? - 浏览器标头是否足够可信以检测他的国家/地区? (en-us en-en en-ca?) 最好的解决方案是什么?
Possible Duplicate:
Location detecting techniques for IP addresses
For our website it's important to know from exactly which country our visitor is coming from.
I guess the best answer for my question would be the simple geo location feature of current browser systems, which just ask the user if the website is allowed to see his geographic location: http://dev.w3.org/geo/api/spec-source.html
but I don't want to bother visitor with questions, I would love to automatically detects the visitor's location (country should be enough.)
What's the best way to do this?
- what ip database would be the best?
- is the browser header trustable enough to detect his country? (en-us en-en en-ca?)
What's the best solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
NetImpact 提供一个免费的 API,用于通过 IP 进行地理位置查找,ProgrammableWeb 也有一个 GeoIP 查找提供商综述。当您的应用程序完成 API 调用时,这会产生少量延迟(除非您的应用程序可以使用非阻塞调用),但这是检测访问者原籍国的侵入性最小的方式。
NetImpact provide a free API for geolocation lookup by IP, ProgrammableWeb also has a roundup of GeoIP lookup providers. This involves a small amount of latency while your application completes an API call (unless your application can use a non-blocking call) but is the least intrusive manner of detecting a visitor's country of origin.
浏览器标头只是告诉您用户想要查看的语言。去日本出差的讲西班牙语的人可能想查看西班牙语网站。
我认为您可以使用反向 IP 服务进行猜测,但如果是出于商业目的,我认为您必须要求用户告诉您。
与地理位置类似:计算机的物理位置可能与浏览网站的用户的需求相关,也可能不相关。
The browser header just tells you what language the user wants to see. A Spanish-speaking person on a business trip to Japan probably wants to see websites in Spanish.
I think you can use reverse-IP services to make a guess, but if it's for commerce purposes I think you have to ask the user to tell you.
Similarly with geo-location: the physical position of the computer may or may not be relevant to the needs of the user browsing the site.
查看 Google Maps API 上的此页面:http:// /code.google.com/apis/maps/documentation/javascript/basics.html#DetectingUserLocation
Have a look at this page on the Google Maps API: http://code.google.com/apis/maps/documentation/javascript/basics.html#DetectingUserLocation
http://www.iplocationtools.com/samples.html 还提供了一组很好的 api做这个。我以前用过他们的系统,非常可靠。
http://www.iplocationtools.com/samples.html also presents a good set of apis to do this. I have used their system before and they were quite reliable.