from __future__ import unicode_literals
from threading import Timer
from wxpy import *
import requests
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]
my_friend.send(get_news1()[0])
my_friend.send(get_news1()[1][5:])
my_friend.send(u"以上是金山词霸每日一句,崔苹正在轰炸你的微信!")
t = Timer(6000000, send_news)
t.start()
except:
my_friend = bot.friends().search('奶瓶仔')[0]
my_friend.send(u"今天消息发送失败了")
if __name__ == "__main__":
send_news()