Skip to content

georgexsh/pyipip

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

PyIPIP

https://travis-ci.org/georgexsh/pyipip.svg?branch=master

Description

ipip.net IPv4 地址归属地数据库 Python 查询库。同时支持 dat 与 datx 格式的数据文件,支持 Python 2 与 3。 需要先去 ipip.net 官方网站 下载数据文件。

性能较官方库为高,在 E5-2682 2.5GHz 下 QPS 约为 490k:

pyipip 491507.74
lxyu 101062.99
official 5701.01

Usage

>>> from pyipip import IPIPDatabase
>>> db = IPIPDatabase('/path/to/your/ipipdb.dat')
>>> db.lookup('202.112.80.106')
'中国\t北京\t北京\t'

Install

pip install pyipip

Test & Benchmark

make test
make bench

Note

数据文件时时更新,请自行下载使用,代码仓库随附的数据文件只用于测试。

About

ipip.net IPv4 地址归属地数据库 Python 查询库

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published