希望使用 Python 实现更好的地理位置.
Hostip.info 是一个开源项目,其目标是构建/维护一个数据库将 IP 地址映射到城市.他们的关于页面解释了填充这个数据库所依赖的数据源.
使用 HostIP,有两种方法可以从 IP 地址获取位置数据:
他们还有一个精心设计且易于使用的 RESTFUL API:只需在 i***p=*** 之后传入您的 IP 地址在 GET 请求字符串中):
导入urllibresponse = urllib.urlopen('http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true').read()打印(响应)
其次,项目网站还提供完整的数据库供下载.p>
Looking to implement better geo-location with Python.
Hostip.info is an open-source project with the goal to build/maintain a database mapping IP addresses to cities. Their about page explains the data sources relied on to populate this database.
Using HostIP, there are two ways to get location data from an IP address:
They also have a well-designed and easy-to-use RESTFUL API: just pass in your ip address after the i***p=*** in the GET request string):
import urllib
response = urllib.urlopen('http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true').read()
print(response)
Second, the Project Website also makes its complete database available for download.
这篇关于在给定 IP 地址的情况下,哪些 python 库可以告诉我大概的位置和时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!