python-itchat 获取微信群用户信息的实例
作者:localhost1113
今天小编就为大家分享一篇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-itchat 获取微信群用户信息的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
您可能感兴趣的文章:
- Python分析微信好友性别比例和省份城市分布比例的方法示例【基于itchat模块】
- Python使用itchat模块实现简单的微信控制电脑功能示例
- python基于itchat模块实现微信防撤回
- Python微信库:itchat的用法详解
- python基于itchat实现微信群消息同步机器人
- python实现微信接口(itchat)详细介绍
- python3操作微信itchat实现发送图片
- 利用python微信库itchat实现微信自动回复功能
- python使用itchat库实现微信机器人(好友聊天、群聊天)
- python itchat实现微信自动回复的示例代码
- python itchat实现微信好友头像拼接图的示例代码
- Python实现清理微信僵尸粉功能示例【基于itchat模块】