python 微信自动发送

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()

猜你喜欢

转载自blog.csdn.net/wangbin0705030219/article/details/91490868
今日推荐