希望使用 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模板网!
python:不同包下同名的两个模块和类python: Two modules and classes with the same name under different packages(python:不同包下同名的两个模块和类)
配置 Python 以使用站点包的其他位置Configuring Python to use additional locations for site-packages(配置 Python 以使用站点包的其他位置)
如何在不重复导入顶级名称的情况下构造python包How to structure python packages without repeating top level name for import(如何在不重复导入顶级名称的情况下构造python包)
在 OpenShift 上安装 python 包Install python packages on OpenShift(在 OpenShift 上安装 python 包)
如何刷新 sys.path?How to refresh sys.path?(如何刷新 sys.path?)
分发带有已编译动态共享库的 Python 包Distribute a Python package with a compiled dynamic shared library(分发带有已编译动态共享库的 Python 包)