Skip to content

Commit

Permalink
phone.dat 更新到2023年02月
Browse files Browse the repository at this point in the history
1、新增“中国广电”号段数据;
2、更新其他号段数据;

因新增了“中国广电”运营商标识,phonedata旧版无法识别广电号段(如:190)显示为“未知电信运营商”, 建议更新phone.dat库的同时更新一下 phonedata 源码到最新版本即可正确识别“中国广电”。

注:前段时间因不可抗力暂停了更新,后续仍将持续更新,感谢您们的关注;
  • Loading branch information
xluo committed Feb 25, 2023
1 parent 9c0b21a commit a7496bc
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
### 这可能是github上能找到的最新最全的中国境内手机号归属地信息库
基于GO语言实现,使用二分查找法。

- 归属地信息库文件大小:4,098,913 字节
- 归属地信息库最后更新:2021年08月
- 手机号段记录条数:454336
- 归属地信息库文件大小:4,484,792 字节
- 归属地信息库最后更新:2023年02月
- 手机号段记录条数:497191

### phone.dat文件格式

Expand Down
Binary file modified phone.dat
Binary file not shown.
4 changes: 4 additions & 0 deletions phonedata.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const (
CTCC_v //电信虚拟运营商
CUCC_v //联通虚拟运营商
CMCC_v //移动虚拟运营商
CBCC //中国广电
CBCC_v //广电虚拟运营商
INT_LEN = 4
CHAR_LEN = 1
HEAD_LENGTH = 8
Expand All @@ -39,9 +41,11 @@ var (
CMCC: "中国移动",
CUCC: "中国联通",
CTCC: "中国电信",
CBCC: "中国广电",
CTCC_v: "中国电信虚拟运营商",
CUCC_v: "中国联通虚拟运营商",
CMCC_v: "中国移动虚拟运营商",
CBCC_v: "中国广电虚拟运营商",
}
total_len, firstoffset int32
)
Expand Down
45 changes: 45 additions & 0 deletions phonedata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,48 @@ func TestFindPhone1669981(t *testing.T) {
}

}

func TestFindPhone1921306(t *testing.T) {

//1921306,河北,保定,中国广电
info, err := Find("1921306")
if err != nil {
t.Fatal("错误的结果")
}
t.Log(info)
str := fmt.Sprintf("%s,%s,%s,%s", info.PhoneNum, info.Province, info.City, info.CardType)
if str != "1921306,河北,保定,中国广电" {
t.Fatal("验证失败")
}

}

func TestFindPhone1936137(t *testing.T) {

//1936137,广东,广州,中国电信
info, err := Find("1936137")
if err != nil {
t.Fatal("错误的结果")
}
t.Log(info)
str := fmt.Sprintf("%s,%s,%s,%s", info.PhoneNum, info.Province, info.City, info.CardType)
if str != "1936137,广东,广州,中国电信" {
t.Fatal("验证失败")
}

}

func TestFindPhone1903845(t *testing.T) {

//1903845,贵州,遵义,中国电信
info, err := Find("1903845")
if err != nil {
t.Fatal("错误的结果")
}
t.Log(info)
str := fmt.Sprintf("%s,%s,%s,%s", info.PhoneNum, info.Province, info.City, info.CardType)
if str != "1903845,贵州,遵义,中国电信" {
t.Fatal("验证失败")
}

}

0 comments on commit a7496bc

Please sign in to comment.