獲取公眾號
#coding=utf8
import itchatitchat.auto_login(hotReload=True)
#返回完整的公眾號列表
mps = itchat.get_mps()
# 獲取名字中含有特定字符的公眾號,也就是按公眾號名稱查找,返回值為一個字典的列表
mps = itchat.search_mps(name='CSDN')print(mps)
#發(fā)送方法和上面一樣userName = mps[0]['UserName']
itchat.send("hello",toUserName = userName)
發(fā)送消息
#coding=utf8
import itchatitchat.auto_login(hotReload=True)
#獲取通訊錄信息
account=itchat.get_friends()
# 獲取自己的UserNameuserName = account[0]['UserName']
#獲取公眾號信息
# mps = itchat.get_mps()
# print(mps)lines = []
#讀取txt文件f = open("/home/numb/Desktop/aaa.txt")?
lines = f.readlines()
#讀取全部內(nèi)容?
#循環(huán)發(fā)送文本內(nèi)容
#UserName需要用上面獲取的自己修改
for i in range(90):
????itchat.send(lines[i],toUserName='UserName') print("Success")