python爬取微信好友信息
首先打开cmd 输入 pip install itchat
#打开cmd窗口 输入命令 pip install itchat
import itchat as it
#设置三个变量 用来统计性别信息
male = 0
female = 0
other = 0
#调用二维码
it.auto_login(False)
#获取好友列表
f = it.get_friends()
for x in f:
if x["Sex"] == 1:
male += 1
if x["Sex"] == 2:
female += 1
if x["Sex"] == 0:
other += 1
print("男性有%d人,女性有%d人,为之性别%d人" % (male,female,other))
运行完后的结果:
其他的信息要爬取的,根据好友列表得到的信息参数进行爬取即可