Skip to content
Projects

ls0f/phone has 1,083 GitHub stars and 230 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-09 10:33 UTC. Last push 2024-09-24.

How these counts are measured

手机号码归属地库 、数据更新:2023年12月

Measured star growth

in 24h
0
in 7 days
Collecting history
in 15 days
Collecting history
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.md

Original

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], 19[2,3,7,9]

记录条数

499527 (updated:2023年12月)

其他语言支持

下载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

MIT

Explore related projects