import json
import requests
# 爬取爱词霸每日鸡汤
def get_iciba_everyday_chicken_soup():
    url = 'http://open.iciba.com/dsapi/'  # 词霸免费开放的jsonAPI接口
    r = requests.get(url)
    all = json.loads(r.text)  # 获取到json格式的内容,内容很多
    # print(all) # json内容,通过这行代码来确定每日一句的键名
    Englis = all['content']  # 找到content属性,提取英文鸡汤
    Chinese = all['note']  # 找到note,提取json中的中文鸡汤
    everyday_soup = Englis+'\n'+Chinese  # 合并需要的字符串内容
    return everyday_soup  # 返回结果

def weixin_push():
    token = '令牌'
    title = '每日鸡汤'  # 标题
    content = get_iciba_everyday_chicken_soup()  # 推送的内容,可以是监控预警的通知,每日鸡汤,天气预告等等。
    url = 'http://pushplus.hxtrip.com/customer/push/send?token=' + token + '&title=' + title + '&content=' + content
    requests.get(url)
    return

if __name__ == '__main__':
    #weixin_push()
最后修改:2020 年 10 月 11 日
如果觉得我的文章对你有用,请随意赞赏