Python拼接微信好友头像大图的实现方法-创新互联
基于 itchat 库来获取微信好友头像并执行拼接操作,对微信上文字化好友列表数据进行可视化展示。

获取好友头像
def save_avatar(folder):
"""
保存微信好友头像
:param folder: 保存的文件夹
"""
itchat.auto_login(hotReload=True)
users = itchat.get_friends() or []
print('%d friends found.' % len(users))
if not os.path.exists(folder):
os.makedirs(folder)
index = 1
for i, user in enumerate(users):
nickname = user.RemarkName
username = user.UserName
file_path = os.path.join(folder, '%03d_%s.png' % (i, nickname))
if not os.path.isfile(file_path): # 不重复下载
avatar = itchat.get_head_img(username)
with open(file_path, 'w') as f:
f.write(avatar)
print('Download %d: %s' % (index, file_path))
index += 1
新闻标题:Python拼接微信好友头像大图的实现方法-创新互联
网站网址:http://www.jxjierui.cn/article/eioip.html


咨询
建站咨询
