# -*- coding: utf-8 -*-
import itchat
# 用于二维码登录微信,
itchat.auto_login()
# 获取通讯录
for friend in itchat.get_friends(update=True)[0:]:
# print(friend['NickName'])
# print(friend['NickName'])
img = itchat.get_head_img(userName=friend["UserName"])
# 保存头像的地址
path = "py_img" + friend['NickName'] + "(" + friend['RemarkName'] + ").jpg"
try:
with open(path, 'wb') as f:
f.write(img)
except Exception as e:
print(repr(e))
# 登出
itchat.run()