从python代码访问sypex geo-ip数据库文件数据的api

pysyge的Python项目详细描述


http://github.com/idlesign/pysyge

LBC Python 2

releaselic

那是什么

pysyge是从python代码中访问sypex geo-ip数据库文件数据的api。

有关Sypex地理数据库及其功能的更多信息,请访问http://sypexgeo.net

随着时间的推移,可能会断开的直接数据库链接:

要求

  • Python2.7+,3.5+

注意

  1. 此版本的pysyge适用于sypex geo db版本2.2或更高版本
The structure of a dictionary returned by GeoLocator.get_location() was preserved in a backward compatible manner as much as possible, yet it’s advised to update your code to use data from info sub dictionary.
  1. 此版本的pysyge与utf-8sypex geo数据库一起工作。pysyge返回的文本是utf-8

快速启动

http://sypexgeo.net/下载geo-ip数据库文件(下面的示例使用SxGeoCityMax.datfile)。

应用程序示例

# Import all we need from pysyge module.frompysygeimportGeoLocator,MODE_BATCH,MODE_MEMORY# Create GeoLocator object to access API# from 'SxGeoCityMax.dat' using fast memory mode.geodata=GeoLocator('SxGeoCityMax.dat',MODE_BATCH|MODE_MEMORY)# Let's get some meta information.print('DB version %s (%s)'%(geodata.get_db_version(),geodata.get_db_date()))# Request geo information for 77.88.21.3 IP address.# Getting detailed information, including region info.location=geodata.get_location('77.88.21.3',detailed=True)# Print out some lyrics.# Most interesting data is under `info` in `city`, `country` and `region` dictionariesprint('%s (%s) calling. All the circuits are busy.'%(location['info']['city']['name_en'],location['info']['country']['iso']))

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何分析。使用烟尘对文件进行分类?   多线程JAVA试图在放入新线程的可运行对象中运行sleep方法   无法在当前目录中运行java程序   java Android查看后保存图像   java反序列化器列表<对象>使用Spring boot的Redis中的值类型,始终抛出错误   java JavaFX文本字段不会更新文本   Java:在方法参数中指定方法?   程序运行时的java ProgressBar   java创建包含数据列表的CSV文件   java使用hibernate连接4个表   java JavaFX maven多模块应用程序打包   Clone()与java中推荐的复制构造函数   java虽然不允许多重继承,但扩展另一个类的类如何扩展对象类?   java JTable不会在fireTableChanged上刷新   java是否可以用<T extends Something>定义一个类,并将该类用作类<?>   在java spring@Scheduled中动态设置不同的cron参数   如何使用sugaronrest在Java中通过其API向SuiteCRM中的潜在客户添加电子邮件?   在eclipse中启动简单maven项目的java问题?