最近在学习 python 突然想要试试能不能把微信里面的微信群和好友取出来 结果百度了一下 找到了 wxpy 这怎么能不试一下呢
用到 wxpy、threading、os、time 四个库
第一步 判断文件夹是否存在 不存在则创建
if not os.path.exists('./info/' + wechat.myself.name):
filepath = os.getcwd()
os.makedirs(filepath + '/info/' + wechat.myself.name + '/headImg')
self.getFriendsList()
第二步 先初始化 并获取当前登录人和好友信息
self.bot = Bot()
self.myself = self.bot.self
self.friends = self.bot.friends()
第三步 循环好友列表并获取好友信息、下载头像
for i in range(len(self.friends)):
if i == 0:
writeType = 'w'
else:
writeType = 'a'
t = threading.Thread(target=self.writeWechatInfo, args=(self.friends[i], writeType, 'f',))
t1 = threading.Thread(target=self.saveHeadImg, args=(self.friends[i],))
t.start()