diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8490e40..7666ac7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,7 @@ jobs: - name: Run sign env: SCKEY: ${{ secrets.SCKEY }} - EMAIL: ${{ secrets.EMAIL }} - PASSWD: ${{ secrets.PASSWD }} + EMAIL: ${{ vars.EMAIL }} + PASSWD: ${{ vars.PASSWD }} run: | python3 ./main.py diff --git a/.github/workflows/main2.yml b/.github/workflows/main2.yml new file mode 100644 index 0000000..8490e40 --- /dev/null +++ b/.github/workflows/main2.yml @@ -0,0 +1,42 @@ +name: "Airport Checkin" + +on: + schedule: + - cron: "0 22 * * *" # scheduled at 06:00 (UTC+8) everyday + workflow_dispatch: + +env: + RUN_ENV: 'prod' + +jobs: + build: + runs-on: ubuntu-latest + # if: github.ref == 'refs/heads/master' + + steps: + - name: Checkout master + uses: actions/checkout@v2 + with: + fetch-depth: 0 + # ref: master + + - name: Set up python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - name: Random sleep + if: github.event_name == 'schedule' + run: sleep $(shuf -i 10-100 -n 1) + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Run sign + env: + SCKEY: ${{ secrets.SCKEY }} + EMAIL: ${{ secrets.EMAIL }} + PASSWD: ${{ secrets.PASSWD }} + run: | + python3 ./main.py diff --git a/README.md b/README.md index 4228c55..a21c7f8 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,12 @@ 1. 右上角Fork此仓库 2. 然后到`Settings`→`Secrets and variables`→`Actions` 新建以下参数: -| 参数 | 内容 | -| ------------ | ------------ | -| EMAIL | 账号邮箱 | -| PASSWD | 账号密码 | -| SCKEY | Sever酱密钥 | -| TOKEN | pushplus密钥 | +| 参数 | 内容 | 变量类型 | +| ------------ | ------------ | ------------ | +| EMAIL | 账号邮箱 | Variables | +| PASSWD | 账号密码 | Variables | +| SCKEY | Sever酱密钥 | Secrets | +| TOKEN | pushplus密钥 | Secrets | 3. 到`Actions`中创建一个workflow,运行一次,以后每天项目都会自动运行。 4. 最后,可以到Run sign查看签到情况,同时也会也会将签到详情推送到Sever酱。 diff --git a/main.py b/main.py index 870d4c3..eb9921b 100644 --- a/main.py +++ b/main.py @@ -2,9 +2,13 @@ session = requests.session() # 配置用户名(一般是邮箱) -email = os.environ.get('EMAIL') +# email = os.environ.get('EMAIL') # 配置用户名对应的密码 和上面的email对应上 -passwd = os.environ.get('PASSWD') +# passwd = os.environ.get('PASSWD') +# 从设置的环境变量中的Variables多个邮箱和密码 ,分割 +emails = os.environ.get('EMAIL', '').split(',') +passwords = os.environ.get('PASSWD', '').split(',') + # server酱 SCKEY = os.environ.get('SCKEY') # PUSHPLUS @@ -24,33 +28,35 @@ def push(content): # 会不定时更新域名,记得Sync fork -login_url = 'https://ikuuu.me/auth/login' -check_url = 'https://ikuuu.me/user/checkin' -info_url = 'https://ikuuu.me/user/profile' +login_url = 'https://ikuuu.pw/auth/login' +check_url = 'https://ikuuu.pw/user/checkin' +info_url = 'https://ikuuu.pw/user/profile' header = { - 'origin': 'https://ikuuu.me', + 'origin': 'https://ikuuu.pw', 'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36' } -data = { + +for email, passwd in zip(emails, passwords): + session = requests.session() + data = { 'email': email, 'passwd': passwd -} -try: - print('进行登录...') - response = json.loads(session.post(url=login_url,headers=header,data=data).text) - print(response['msg']) - # 获取账号名称 - info_html = session.get(url=info_url,headers=header).text -# info = "".join(re.findall('(.*?)', info_html, re.S)) -# print(info) - # 进行签到 - result = json.loads(session.post(url=check_url,headers=header).text) - print(result['msg']) - content = result['msg'] - # 进行推送 - push(content) -except: - content = '签到失败' - print(content) - push(content) + } + try: + print(f'[{email}] 进行登录...') + response = json.loads(session.post(url=login_url,headers=header,data=data).text) + print(response['msg']) + # 获取账号名称 + # info_html = session.get(url=info_url,headers=header).text + # info = "".join(re.findall('(.*?)', info_html, re.S)) + # 进行签到 + result = json.loads(session.post(url=check_url,headers=header).text) + print(result['msg']) + content = result['msg'] + # 进行推送 + push(content) + except: + content = '签到失败' + print(content) + push(content)