好友
阅读权限10
听众
最后登录1970-1-1
|
本帖最后由 culprit 于 2021-2-25 14:05 编辑
往期云函数
【修改版】腾讯云函数实现每日天气推送:https://www.52pojie.cn/thread-1270946-1-1.html
-------------------------------------------------------
2021/2/25更新,入口函数填写index.Qmsg_Push
[Python] 纯文本查看 复制代码 import requests, json,random
api_token = 'xxx' #到https://www.alapi.cn/注册账号申请token
qmsg_key = 'xxx' #到https://qmsg.zendee.cn/注册账号申请key
def getData():
api_url = ['https://v2.alapi.cn/api/qinghua', 'https://v2.alapi.cn/api/dog']
url = random.choice(api_url)
header = {
'token':api_token
}
r = requests.get(url,headers=header)
r.encoding = r.apparent_encoding
res = r.json()
try:
if res['code'] == 200:
data = res['data']['content']
except:
pass
if url == api_url[0]:
data = '今日为您推送土味情话:\n' + data
elif url == api_url[1]:
data = '今日为您推送舔狗日记:\n' + data
else:
pass
return data
def Qmsg_Push(arg1,arg2):
push_url = "https://qmsg.zendee.cn/send/" + qmsg_key
post_data = {
'msg': getData()
}
requests.post(push_url,data=post_data)
print(post_data)
-------------------------------------------------------
2020/9/21
代码如下:
[Python] 纯文本查看 复制代码 import requests,datetime,random
key = '填你自己的key'
def main():
now = datetime.datetime.now()
api = 'https://www.we.dog//assets/js/index.js'
eed = requests.get(api).text
e = eed[10:-266]
e1 = e.split(",")
res = random.choice(e1).strip("'")
now_time = ' {}-{}-{} {}:{}:{}'.format(now.year, now.month, now.day, now.hour,
now.minute, now.second)
push_url = "推送地址" + key
post_data = res + "\n" + now_time
# requests.post(push_url, post_data.encode("utf-8"))
print(post_data)
if __name__ == '__main__':
main()
测试截图:
|
免费评分
-
查看全部评分
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|