如下所示:

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 获取微信群用户信息的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!

稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!

昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。

这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。

而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?