久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

用python發送微信消息

瀏覽:135日期:2022-07-01 16:05:19
條件

1、能夠上網

2、必須是你的好友

3、必須能二維碼登錄網頁微信

發送示例

# 使用微信接口給微信好友發送消息,import itchat # 自動登錄方法,hotReload=True可以緩存,不用每次都登錄,但是第一次執行時會出現一個二維碼,需要手機微信掃碼登錄itchat.auto_login(hotReload=False) # 搜索好友,search_friends('xxx'),其中'xxx'為好友昵稱,備注或微信號不行userfinfo = itchat.search_friends('顧正') # '智能群管家014'為好友昵稱print('userfinfo:',userfinfo)# print(userfinfo),獲取userinfo中的UserName參數userid = userfinfo[0]['UserName'] # 獲取用戶id # 調用微信接口發送消息itchat.send('陳軍是不是傻?', userid) # 通過用戶id發送信息# 或itchat.send_msg(msg=’好像是的’, toUserName=userid) # 發送純文本信息

用python發送微信消息

定時發送消息

# -*- coding: UTF-8 -*-import itchatimport timeimport requests#獲取金山詞霸每日一句def get_new(): url='http://open.iciba.com/dsapi' r=requests.get(url) contents=r.json()[’content’] note=r.json()[’note’] return contents,notedef send_news(): try:itchat.auto_login(hotReload=True)my_friend=itchat.search_friends(name=u’卡2’)FriendName=my_friend[0]['UserName']message1=get_new()[0]#因為會出現進程報錯,所以我加上了 passpassmessage2=get_new[1]passmessage3=u'來自你的朋友'passitchat.send(message1,toUserName=FriendName)itchat.send(message2, toUserName=FriendName)itchat.send(message3, toUserName=FriendName)#每個1天發送消息t=time(86400,send_news())t.start() except:#如果上面其中一條消息沒有發送成功,就會發送本條消息message4=u'你的朋友出bug了'itchat.send(message4,toUserName=FriendName) if __name__=='__main__': send_news()

以上就是用python發送微信消息的詳細內容,更多關于python 發送微信消息的資料請關注好吧啦網其它相關文章!

標簽: 微信 Python
相關文章:
主站蜘蛛池模板: 皋兰县| 玉龙| 潍坊市| 西丰县| 三明市| 汉寿县| 夏津县| 兰考县| 泽州县| 永昌县| 瑞安市| 佛学| 普宁市| 台州市| 富川| 璧山县| 德州市| 大化| 南皮县| 甘孜县| 疏勒县| 长岭县| 安仁县| 兰州市| 通海县| 辽阳县| 鄂托克旗| 郧西县| 湖南省| 潜江市| 平邑县| 邹平县| 文水县| 阜新| 宜州市| 连城县| 乌兰浩特市| 苍山县| 萨迦县| 茌平县| 泽普县|