您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關(guān)python-itchat如何獲取微信群用戶信息的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。
如下所示:
import itchat, time from itchat.content import TEXT #name = ' ' roomslist = [] itchat.auto_login(enableCmdQR = False) def getroom_message(n): #獲取群的username,對(duì)群成員進(jìn)行分析需要用到 itchat.dump_login_status() # 顯示所有的群聊信息,默認(rèn)是返回保存到通訊錄中的群聊 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這一參數(shù)為二維碼在下面控制臺(tái)中顯示出來(lái),而不是用圖片顯示 # # 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常用的庫(kù):1.requesuts;2.scrapy;3.pillow;4.twisted;5.numpy;6.matplotlib;7.pygama;8.ipyhton等。
感謝各位的閱讀!關(guān)于“python-itchat如何獲取微信群用戶信息”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。