雨云自动签到 Github Action 代码

创建一个新的Github仓库,然后在Action页面创建一个新的workflow,随便起个名字。此操作可以在网上搜索到教程,不多赘述。

在workflow文件(路径类似 .github/workflows/example.yml)中填入以下代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
name: Rainyun
on:
workflow_dispatch:
schedule:
# 定时任务
- cron: '0 20 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: 'Set up Python'
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: 'Do task'
run:
python ./rainyun.py

再在仓库根目录,新建 rainyun.py,填入以下代码:

(可根据个人需求更改最后一行的 python ./rainyun.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import http.client
import json

conn = http.client.HTTPSConnection("api.v2.rainyun.com")
payload = json.dumps({
"task_name": "每日签到"
})
headers = {
'x-api-key': '{此处填入你的api密钥}',
'User-Agent': 'Mozilla/5.0',
'Content-Type': 'application/json'
}
conn.request("POST", "/user/reward/tasks", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

注意修改请求头中的 x-api-key参数。你可以在 https://app.rainyun.com/account/settings 找到自己的API密钥。

在该Action的页面可以直接运行代码,以便测试。


雨云自动签到 Github Action 代码
https://www.yuanzj.top/posts/90841a9b.html
作者
yzl3014
发布于
2024年3月14日
许可协议