python-itchat 获取微信群用户信息的实例
2019/7/14 23:31:43
本文主要是介绍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 获取微信群用户信息的实例的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-24Python编程基础详解
- 2024-11-21Python编程基础教程
- 2024-11-20Python编程基础与实践
- 2024-11-20Python编程基础与高级应用
- 2024-11-19Python 基础编程教程
- 2024-11-19Python基础入门教程
- 2024-11-17在FastAPI项目中添加一个生产级别的数据库——本地环境搭建指南
- 2024-11-16`PyMuPDF4LLM`:提取PDF数据的神器
- 2024-11-16四种数据科学Web界面框架快速对比:Rio、Reflex、Streamlit和Plotly Dash
- 2024-11-14获取参数学习:Python编程入门教程