Giter VIP home page Giter VIP logo

phone-1's Introduction

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:2017年4月)

其他语言支持

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

phone-1's People

Contributors

lovedb0y avatar ls0f avatar moezen avatar neoblackcap avatar stiekel avatar xluohome avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.