Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

lnln60/phone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

36 Commits

Repository files navigation

Build Status

手机号码库

安装

使用pip安装:

pip install phone

或者直接clone源码。

使用:

from phone import Phone
p = Phone()
p.find(1888888)

支持号段

13*,15*,18*,14[5,7],17[0,6,7,8]

记录条数

360569 (updated:2018年10月)

其他语言支持

下载phone.dat文件,用其他语言解析即可。

phone.dat文件格式


 | 4 bytes | <- phone.dat 版本号
 ------------
 | 4 bytes | <- 第一个索引的偏移
 -----------------------
 | offset - 8 | <- 记录区
 -----------------------
 | index | <- 索引区
 -----------------------
  • 头部 头部为8个字节,版本号为4个字节,第一个索引的偏移为4个字节(<4si)。
  • 记录区 中每条记录的格式为"<省份>|<城市>|<邮编>|<长途区号>0円"。 每条记录以'0円'结束。
  • 索引区 中每条记录的格式为"<手机号前七位><记录区的偏移><卡类型>",每个索引的长度为9个字节(<iiB)。

解析步骤:

  • 解析头部8个字节,得到索引区的第一条索引的偏移。
  • 在索引区用二分查找得出手机号在记录区的记录偏移。
  • 在记录区从上一步得到的记录偏移处取数据,直到遇到'0円'。

我定义的卡类型为:

  • 1 移动
  • 2 联通
  • 3 电信
  • 4 电信虚拟运营商
  • 5 联通虚拟运营商
  • 6 移动虚拟运营商

License

About

手机号码归属地库

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages

  • Python 100.0%

AltStyle によって変換されたページ (->オリジナル) /