from __future__ import unicode_literals
from threading import Timer
from wxpy import *
import requests
import random
bot = Bot()
def get_news():
url = "http://open.iciba.com/dsapi/"
r = requests.get(url)
content = r.json()['content']
note = r.json()['note']
return content, note
def send_news():
try:
contents = get_news()
my_friend = bot.friends().search('文件传输助手')[0]
my_friend.send(u"朱炜是个大傻叉")
t = Timer(10, send_news)
t.start()
except:
my_friend = bot.friends().search('游泳的鱼')[0]
my_friend.send(u"今天消息发送失败了")
if __name__ == "__main__":
send_news()