惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google Online Security Blog
Google Online Security Blog
博客园_首页
酷 壳 – CoolShell
酷 壳 – CoolShell
Jina AI
Jina AI
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
V
V2EX
雷峰网
雷峰网
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
F
Full Disclosure
Y
Y Combinator Blog
V
V2EX - 技术
Attack and Defense Labs
Attack and Defense Labs
S
Security @ Cisco Blogs
Schneier on Security
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
SecWiki News
SecWiki News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The GitHub Blog
The GitHub Blog
量子位
PCI Perspectives
PCI Perspectives
S
Secure Thoughts
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AWS News Blog
AWS News Blog
Blog — PlanetScale
Blog — PlanetScale
爱范儿
爱范儿
K
Kaspersky official blog
B
Blog
A
Arctic Wolf
Hacker News: Ask HN
Hacker News: Ask HN
L
LangChain Blog
T
Tor Project blog
P
Privacy & Cybersecurity Law Blog
Recent Announcements
Recent Announcements
宝玉的分享
宝玉的分享
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
Lohrmann on Cybersecurity
D
Docker
A
About on SuperTechFans
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
The Last Watchdog
The Last Watchdog
S
Security Affairs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy International News Feed
Simon Willison's Weblog
Simon Willison's Weblog

6Jyc5p+a

【笔记】Solidity计算字符串的MD5值 【笔记】Hardhat学习笔记 【笔记】Go安装笔记 【笔记】CVE-2024-3094漏洞利用 【笔记】CVE-2026-43284和CVE-2026-43500漏洞利用 【笔记】CVE-2023-3567漏洞利用 【代码】Python3读写M1卡 【笔记】M1卡学习笔记 【笔记】Python3中文转拼音 【代码】Python3生成中国大陆姓名拼音 【笔记】Nodejs发送请求 【笔记】Trello通过API添加待办事项 【笔记】Nodejs的流和缓冲区 【笔记】Nodejs的事件 【笔记】Nodejs的文件和目录操作 【笔记】CNVD-2020-10487漏洞利用 【笔记】CVE-2017-12617漏洞利用 【笔记】PHP输出源码 【笔记】PHP的Phar 【笔记】通过Docker部署OnlineTools 【笔记】XML学习笔记 【笔记】Windows的用户和组 【笔记】CVE-2006-7243漏洞利用 【代码】JS将目录编号转换为十六进制 【笔记】PHP抑制所有报错 【笔记】HFish学习笔记 【笔记】JumpServer学习笔记 【笔记】Conpot学习笔记 【笔记】南墙WAF学习笔记 【笔记】堡塔云WAF学习笔记 【笔记】Windows的远程桌面服务 【笔记】Windows的防火墙
【代码】Python3爬取中国大陆手机号段
6Jyc5p+a · 2026-06-03 · via 6Jyc5p+a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import time

import requests
from bs4 import BeautifulSoup
import lxml

province_list = ["山东", "江苏", "安徽", "四川", "陕西", "湖北", "广东", "广西", "浙江", "河南", "甘肃", "吉林", "辽宁", "内蒙古", "新疆", "黑龙江", "福建", "河北", "海南", "江西", "山西", "湖南", "青海", "贵州", "宁夏", "云南", "西藏"]
main_province_list = ["北京", "天津", "上海", "重庆"]
operator_list = {
"中国联通": [130, 131, 132, 145, 146, 155, 156, 166, 167, 171, 175, 176, 185, 186, 196],
"中国电信": [133, 141, 149, 153, 162, 170, 173, 174, 177, 180, 181, 189, 190, 191, 193, 199],
"中国移动": [134, 135, 136, 137, 138, 139, 147, 148, 150, 151, 152, 157, 158, 159, 165, 172, 178, 182, 183, 184, 187, 188, 195, 197, 198],
"中国广电": [192]
}

base_url = "https://telphone.cn"


for operator_name, number_segment_list in operator_list.items():

for number_segment in number_segment_list:

for province in province_list:
html_province = requests.get(f"{base_url}/prefix/{province}{number_segment}").text
soup_province = BeautifulSoup(html_province, 'lxml')
a_list_province = soup_province.select("section")[0].select(".list-box__grid .list-box__item a")

for a_province in a_list_province:
city = a_province.attrs["href"][1:-1].split("/")[1].split("1")[0]
html_city = requests.get(f"{base_url}/prefix/{city}{number_segment}").text
soup_city = BeautifulSoup(html_city, 'lxml')
a_list_city = soup_city.select("section")[0].select(".list-box__grid .list-box__item a")
for a_city in a_list_city:
number_prefix = a_city.attrs["href"][1:-1].split("/")[1]
with open("phone-number-prefix.dic", "a") as f:
f.write(f"{number_prefix}\n")
print(f"写入文件完成: {number_segment} - {province} - {city} - {number_prefix}")
print(f"等待1s")
time.sleep(1)
print(f"{number_segment} - {province} 全部完成")
print("所有省份全部完成")


for operator_name, number_segment_list in operator_list.items():

for number_segment in number_segment_list:

for province in main_province_list:
html_province = requests.get(f"{base_url}/prefix/{province}{number_segment}").text
print(html_province)
soup_province = BeautifulSoup(html_province, 'lxml')
a_list_province = soup_province.select(".section-box")[0].select(".list-box__grid .list-box__item a")
for a_province in a_list_province:
number_prefix = a_province.attrs["href"][1:-1].split("/")[1]
with open("phone-number-prefix.dic", "a") as f:
f.write(f"{number_prefix}\n")
print(f"写入文件完成: {province} - {number_prefix}")
print(f"{number_segment} - {province} 全部完成")
print("所有直辖市全部完成")
print("结束")