資源簡介
基于python;
每天可以給指定人發消息;
可以每天整點定時;

代碼片段和文件信息
from?__future__?import?unicode_literals
from?threading?import?Timer
from?wxpy?import?*
import?requests
bot?=?Bot()
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(‘dumpling‘)[0]
my_friend.send(get_news1()[0])
my_friend.send(get_news1()[1][5:])
my_friend.send(“Cxs!“)
t?=?Timer(86400send_news)?#?每86400秒(1天),發送1次,不用linux的定時任務是因為每次登陸都需要掃描二維碼登陸,很麻煩的一件事,就讓他一直掛著吧
t.start()
except:
my_friend?=?bot.friends().search(‘O_o‘)[0]?????#?你的微信名稱,不是微信帳號。
my_friend.send(u“今天消息發送失敗了“)
if?__name__?==?“__main__“:
send_news()
#https://www.cnblogs.com/jaycekon/archive/2017/07/17/WxpyRedis.html
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1018??2018-04-11?22:31??python每天發消息\Send_Friends.py
?????目錄??????????0??2018-04-12?00:11??python每天發消息
-----------?---------??----------?-----??----
?????????????????1018????????????????????2
- 上一篇:實現火車票查詢python.zip
- 下一篇:python 打磚塊源代碼
評論
共有 條評論