您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
这篇文章给大家分享的是有关python-itchat如何获取微信群用户信息的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
如下所示:
import itchat, time from itchat.content import TEXT #name = ' ' roomslist = [] itchat.auto_login(enableCmdQR = False) def getroom_message(n): #获取群的username,对群成员进行分析需要用到 itchat.dump_login_status() # 显示所有的群聊信息,默认是返回保存到通讯录中的群聊 RoomList = itchat.search_chatrooms(name=n) if RoomList is None: print("%s group is not found!" % (name)) else: return RoomList[0]['UserName'] def getchatrooms(): #获取群聊列表 roomslist = itchat.get_chatrooms() #print(roomslist) return roomslist for i in getchatrooms(): #print(i['NickName']) roomslist.append(i['NickName']) with open('群用户名.txt', 'a', encoding='utf-8')as f: for n in roomslist: ChatRoom = itchat.update_chatroom(getroom_message(n), detailedMember=True) for i in ChatRoom['MemberList']: #print (i['Province']+":",i['NickName']) f.write(i['Province']+":"+i['NickName']+'\n') print('正在写入 '+i['Province']+":",i['NickName']) f.close() # for i in ChatRoom: # print(i['MemberList']['ContactList']) # count += 1 # print(count) # # @itchat.msg_register(TEXT) # # def simple_reply(TEXT): # # print(msg.text) # # # # itchat.auto_login(enableCmdQR = False,hotReload = True) # enableCmdQR=True这一参数为二维码在下面控制台中显示出来,而不是用图片显示 # # itchat.run() # itchat.auto_login(enableCmdQR = False) # # # time.sleep() # # itchat.logout() # # friends = itchat.get_friends() # # for i in friends: # # print(i) # rooms = itchat.get_chatrooms() # for i in rooms: # print(i['NickName']) # memberList = itchat.update_chatroom(i['NickName']) # print (memberList) # # # room = itchat.update_chatroom(i['NickName'],detailedMember = True) # # print(room) # # # for i in room: # # # print(i)
python常用的库:1.requesuts;2.scrapy;3.pillow;4.twisted;5.numpy;6.matplotlib;7.pygama;8.ipyhton等。
感谢各位的阅读!关于“python-itchat如何获取微信群用户信息”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。