本来想爬微信公众号的,突然想起这个,自己以前就想做的事,结果网上一搜一大把,参照一篇博客,几分钟就能写出来
直接贴代码:
ps:search里是写你微信好友自己的昵称,不是备注!不是备注!不是备注!
# coding=utf-8
from threading import Timer
from wxpy import *
import requests
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:
content,note = get_news()
my_friend = bot.friends().search(u\'少爷\')[0]
my_friend.send(content)
my_friend.send(note)
my_friend.send(u\'我在胡建等你~!\')
t = Timer(60, send_news)
t.start()
except:
my_friend = bot.friends().search(u\'舒然\')[0]
my_friend.send(u\'啊哦,你最好看一下,今天发送失败了\')
if __name__ == \'__main__\':
send_news()
是不是很简单???
参照博客:传送门
继续阅读与本文标签相同的文章
-
一年一度的硬核科技盛会——杭州云栖大会就要来了! | 开发者必读(059期)
2026-05-18栏目: 教程
-
在QQ空间保存着的明明很清楚照片放时间长了为何会变模糊?
2026-05-18栏目: 教程
-
吹爆这五款APP,每一款手机必备,不知道蛮可惜的
2026-05-18栏目: 教程
-
报销内容大同小异,可以直接套用模板数据吗?
2026-05-18栏目: 教程
-
美国男性机器人诞生,满足用户“硬需”,96%的女性用户都满意
2026-05-18栏目: 教程
