Python导出微信群成员itchat

import itchat
itchat.auto_login(hotReload=True)#hotReload=True
for room in itchat.get_chatrooms(update=True)[0:]:
    chatroom=itchat.update_chatroom(room['UserName'],detailedMember=True)
    path="C:/Users/Administrator/Documents/group/"+room['NickName']+'.txt'
    try:
         with open(path,'a',encoding='utf-8') as f:
             i=1
             for friend in chatroom['MemberList']:
                if friend['DisplayName']=='':
                    friend['DisplayName']='No_DisplayName'
                f.write(repr(i)+'.'+friend['DisplayName']+'     '+friend['NickName']+'\n')
                i+=1
    except Exception as e:
              print(repr(e))
itchat.run()
0

发表评论

邮箱地址不会被公开。 必填项已用*标注