85 lines
2.7 KiB
Markdown
85 lines
2.7 KiB
Markdown
|
# 通过QQ账号批量获取用户手机号
|
|||
|
|
|||
|
2023-08-05 更新内容
|
|||
|
新增多线程模式
|
|||
|
|
|||
|
|
|||
|
萌狼蓝天 | 2023-08-04
|
|||
|
|
|||
|
## 说明
|
|||
|
此文件是批量将Excel表格中的QQ号读取到MongoDB中,然后依次读取MongoDB中的数据,进行业务请求,获取需要的数据,将获取到的数据保存的MongoDB中
|
|||
|
|
|||
|
## Code
|
|||
|
导入相关的包和准备数据库
|
|||
|
```python
|
|||
|
import json
|
|||
|
import pandas as pd
|
|||
|
import package_info as obj
|
|||
|
import pymongo
|
|||
|
myclient = pymongo.MongoClient('localhost', 27017) # 连接MongoDB
|
|||
|
db = myclient['temp_user_info']
|
|||
|
DataYuan = db['qqandtel']
|
|||
|
DataResult = db["result"]
|
|||
|
```
|
|||
|
|
|||
|
|
|||
|
下面的代码只能执行一遍,执行完注释掉,避免重复导入Excel表格数据到MongoDB
|
|||
|
```python
|
|||
|
# 将这一千条数据添加到Mongodb
|
|||
|
result = pd.read_excel("第一批.xlsx",sheet_name="Sheet1",header=0)["QQ号"]
|
|||
|
print(result)
|
|||
|
for i in result:
|
|||
|
DataYuan.insert_one({"QQ号":i})
|
|||
|
# 数据添加完毕,请勿重复执行,因此上述代码注释掉
|
|||
|
```
|
|||
|
|
|||
|
下面的代码是读取MongoDB中的QQ号,利用循环逐一的获取对应电话号码
|
|||
|
由于可能会存在请求失败的情况,请求失败的,因此需要多执行几次。
|
|||
|
对于获取成功的QQ号,会将MongoDB里面的QQ号删除掉,避免重复执行的时候,重复获取,导致重复添加到结果
|
|||
|
```python
|
|||
|
|
|||
|
now = 0
|
|||
|
for i in DataYuan.find():
|
|||
|
count = DataYuan.find().count()
|
|||
|
qq = (i["QQ号"])
|
|||
|
result = obj.API_FromQQtoALl(qq)
|
|||
|
code = result["code"]
|
|||
|
data = result["data"]
|
|||
|
if code==-1:
|
|||
|
# DataYuan.insert({"QQ号":qq}) # 没有删除,因此也无需添加
|
|||
|
pass
|
|||
|
else:
|
|||
|
DataResult.insert_one({"QQ":data['qq'],"手机号码":data['tel'],'手机归属地':data['address'],'微博ID':data['id']})
|
|||
|
DataYuan.delete_one({"QQ号":qq})
|
|||
|
now=now+1
|
|||
|
print(str(now)+"/"+str(count))
|
|||
|
|
|||
|
|
|||
|
```
|
|||
|
|
|||
|
|
|||
|
==================================================================
|
|||
|
Congratulations! Installed successfully!
|
|||
|
========================面板账户登录信息==========================
|
|||
|
|
|||
|
外网面板地址: https://124.71.108.214:12536/633ec6bf
|
|||
|
内网面板地址: https://192.168.0.159:12536/633ec6bf
|
|||
|
username: f23cy54c
|
|||
|
password: 38ddd3ac
|
|||
|
|
|||
|
=========================打开面板前请看===========================
|
|||
|
|
|||
|
【云服务器】请在安全组放行 12536 端口
|
|||
|
因默认启用自签证书https加密访问,浏览器将提示不安全
|
|||
|
点击【高级】-【继续访问】或【接受风险并继续】访问
|
|||
|
教程:https://www.bt.cn/bbs/thread-117246-1-1.html
|
|||
|
|
|||
|
==================================================================
|
|||
|
|
|||
|
|
|||
|
|
|||
|
外网面板地址: https://43.156.233.131:16600/f2969f8a
|
|||
|
内网面板地址: https://10.0.0.2:16600/f2969f8a
|
|||
|
username: j4dznejf
|
|||
|
password: f980ca1b
|