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))
运行完后的结果:

其他的信息要爬取的,根据好友列表得到的信息参数进行爬取即可
本文介绍使用Python的itchat库实现微信好友信息爬取的方法,包括安装库、登录、获取好友列表及统计性别比例等关键步骤。

1365

被折叠的 条评论
为什么被折叠?



