QQ 空间爬虫

最近又想不出来 QQ 改名要改什么名字了x.

于是发现可以写一个爬虫, 获取所有 QQ 用户姓名然后筛选. 如果有可能的话说不定可以用 Tensorflow 筛选呢.

也就贴一下代码吧.

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
import requests
import json
import time
from util.RemoveCallback import remove_callback


def get_username_and_pic(uid, retry=3):

while True:
try:
res = requests.get("https://r.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg", verify=False, params={
"uins": uid
}, timeout=1)
break
except Exception as e:
retry -= 1
time.sleep(1)
if retry <= 0:
raise e

try:
res = json.loads(remove_callback(res.content.decode("gbk")))
except Exception as e:
print(e)
try:
res = json.loads(remove_callback(res.content.decode("utf-8")))
except Exception as e2:
print(e2)

name = res[str(uid)][6]
pic = res[str(uid)][0]
if name.replace(' ', '') != '':
return name, pic
else:
raise Exception("Failed to get name: RAW: " + str(res))


打赏支持
“请我吃糖果~o(*^ω^*)o”
QQ 空间爬虫
https://blog.lyc8503.site/post/qzone-name-crawler/
作者
lyc8503
发布于
2020年3月13日
许可协议