国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

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

用python發送微信消息

瀏覽:124日期: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
相關文章:
主站蜘蛛池模板: 沂源县| 苏尼特左旗| 阜宁县| 遵化市| 吉林省| 砀山县| 中方县| 南充市| 南宁市| 博白县| 遂宁市| 瑞丽市| 丰原市| 平安县| 拉萨市| 巍山| 来安县| 桐柏县| 化隆| 剑阁县| 民县| 濮阳县| 南充市| 南康市| 永济市| 云龙县| 新郑市| 霸州市| 四平市| 郓城县| 达尔| 菏泽市| 视频| 华池县| 霍城县| 遂昌县| 新乡县| 韶关市| 枣强县| 镇雄县| 沂源县|