什么样的python库可以告诉我给出IP地址的大概位置和时区? [英] What python libraries can tell me approximate location and time zone given an IP address?

查看:113
本文介绍了什么样的python库可以告诉我给出IP地址的大概位置和时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

推荐答案

解决方案

www.hostip.info/rel =noreferrer> Hostip.info 是一个开源项目,其目标是建立/维护一个将IP地址映射到城市的数据库 即可。他们的 about 页面解释了依赖于填充此数据库的数据源。

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.

使用HostIP,有两种方法可以从IP获取位置数据地址:

Using HostIP, there are two ways to get location data from an IP address:

他们还有一个设计良好且易于使用的RESTFUL API :只需传入您的IP地址在GET请求字符串中的i *** p = ***之后):

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.

这篇关于什么样的python库可以告诉我给出IP地址的大概位置和时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆