python實(shí)現(xiàn)向微信用戶發(fā)送每日一句 python實(shí)現(xiàn)微信聊天機(jī)器人
更新時(shí)間:2019年03月27日 14:55:50 作者:回憶是如此憂傷
這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)向微信用戶發(fā)送每日一句,python調(diào)實(shí)現(xiàn)微信聊天機(jī)器人,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
分享幾個(gè)Python針對(duì)微信的小工具,供大家參考,具體內(nèi)容如下
用Python實(shí)現(xiàn)向微信用戶發(fā)送每日一句
# -*- coding:utf-8 -*- from __future__ import unicode_literals from threading import Timer from wxpy import * import requests #bot = Bot() #bot = Bot(console_qr=2,cache_path="botoo.pkl")#這里的二維碼是用像素的形式打印出來!,如果你在win環(huán)境上運(yùn)行,替換為 bot=Bot() bot = Bot(cache_path=True) def get_news1(): #獲取金山詞霸每日一句,英文和翻譯 url = "http://open.iciba.com/dsapi/" r = requests.get(url) contents = r.json()['content'] translation= r.json()['translation'] return contents,translation def send_news(): try: my_friend = bot.friends().search(u'浩')[0] #你朋友的微信名稱,不是備注,也不是微信帳號(hào)。 my_friend.send(get_news1()[0]) my_friend.send(get_news1()[1][5:]) my_friend.send(u"以上是金山詞霸每日一句,http://www.qq.com\" data-miniprogram-appid=\"wxae430cc3e778834b\" data-miniprogram-path=\"pages/goLogin/goLogin\"") t = Timer(10, send_news)#每86400秒(1天),發(fā)送1次,不用linux的定時(shí)任務(wù)是因?yàn)槊看蔚顷懚夹枰獟呙瓒S碼登陸,很麻煩的一件事,就讓他一直掛著吧 t.start() except: my_friend = bot.friends().search('回憶總是如此傷')[0]#你的微信名稱,不是微信帳號(hào)。 my_friend.send(u"今天消息發(fā)送失敗了") if __name__ == "__main__": send_news()
用Python調(diào)用圖靈機(jī)器人接口實(shí)現(xiàn)微信聊天機(jī)器人
import kivy kivy.require('1.9.1') from kivy.app import App from kivy.uix.button import Button import itchat import requests class test(App): def get_response(msg): apiUrl = 'http://www.tuling123.com/openapi/api' data = { 'key': '0646d90819004f2fa565852c0fe3c3af', # Tuling Key 'info': msg, # 這是我們發(fā)出去的消息 'userid': '123', # 這里你想改什么都可以 } # 我們通過如下命令發(fā)送一個(gè)post請求 r = requests.post(apiUrl, data=data).json() return r.get('text') @itchat.msg_register(itchat.content.TEXT) def print_content(msg): return get_response(msg['Text']) @itchat.msg_register([itchat.content.TEXT], isGroupChat=True) def print_content(msg): return get_response(msg['Text']) itchat.auto_login(True) itchat.run() if __name__ == '__main__': test().run()
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
PyTorch一小時(shí)掌握之a(chǎn)utograd機(jī)制篇
這篇文章主要介紹了PyTorch一小時(shí)掌握之a(chǎn)utograd機(jī)制篇,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-09-09python hough變換檢測直線的實(shí)現(xiàn)方法
這篇文章主要介紹了python hough變換檢測直線的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07

Python實(shí)現(xiàn)自動(dòng)識(shí)別并填加驗(yàn)證碼的示例代碼
實(shí)現(xiàn)自動(dòng)識(shí)別網(wǎng)頁中的驗(yàn)證碼并填寫,需要結(jié)合使用網(wǎng)絡(luò)爬蟲技術(shù)、圖像識(shí)別(OCR),以及可能的瀏覽器自動(dòng)化工具(如Selenium),本文給大家介紹了Python實(shí)現(xiàn)自動(dòng)識(shí)別并填加驗(yàn)證碼的示例,需要的朋友可以參考下
2024-06-06 
python+selenium 鼠標(biāo)事件操作方法
今天小編就為大家分享一篇python+selenium 鼠標(biāo)事件操作方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
2019-08-08