签到脚本,签到成功结果,消息推送到钉钉群
博主亲测可用~
Python脚本每日自动签到GLaDOS,增加1天会员时间,并且把签到结果报告到钉钉群!
官方:GLaDOS 官方 github,GLaDOS 官网。
如果您还没有注册的话,可以去这里注册,然后填写邀请码:DHFLJ-25LQF-90SQ4-U54F6
。双方都可以获得3天奖励天数哦~
使用步骤如下
1、获取 cookie
在 GLaDOS 的网页上按 F12,进行请求,查看请求的 cookie。
2、设置 cookie
COOKIE
示例:
__cfduid=d526a2a21******c5521611332007; _ga=GA1.2.101***3158.1611332010; _gid=GA1.2.11***23.1611332010; koa:sess=eyJ1c2VyS******fZXhwaXJlIjoxNjM3MjU0NjEzMTEyLCJfbWF4QWd****yMDAwMDAwMH0=; koa:sess.sig=m6KAoBnv1s***DldbtvNw1v8; _gat_gtag_UA_10***600_2=1
执行脚本
cat bash.sh
#!/bin/bash
echo "---------GLaDos签到---------------"
# glados签到 https://www.glados.rocks/
/usr/bin/python3 /home/ghy/glados.py
定时任务
# 定时签到任务
0 9,12,18 * * * /usr/bin/bash /home/ghy/bash.sh >> /home/ghy/log/checkin_$(date +""\%Y-\%m-\%d_\%T"").log 2>&1
# 每隔15天删除30天以上的签到日志文件
* * */15 * * /usr/bin/find /home/ghy/log/ -mtime +30 -name "*.log" -exec rm -rf {} \;
安装Python3
yum install python3
pip安装request模块
pip3 install requests -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
查看pip已经安装的模块
pip3 list
certifi (2022.12.7)
charset-normalizer (2.0.12)
idna (3.4)
pip (9.0.3)
requests (2.27.1)
setuptools (39.2.0)
urllib3 (1.26.15)
签到Python脚本
#!/usr/bin/python3
# -*- coding: utf-8 -*
import requests
import json
# 替换成你的glados账号cookie
cookie = 'xxxxxxx'
# webhook为你的钉钉机器人的webhook地址
webhook = 'xxxxxxx'
def main():
checkin_res = checkin()
if checkin_res == "Please Try Tomorrow":
print("签到失败,请明天再试!")
else:
state_res = get_state()
content = f'高宏宇,当前天数:{state_res} \n签到结果:{checkin_res}'
send_dingtalk(content)
def checkin():
url = 'https://glados.rocks/api/user/checkin'
headers = {
'cookie': cookie,
'origin': 'https://glados.rocks',
'referer': 'https://glados.rocks/console/checkin',
'content-type': 'application/json;charset=UTF-8',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36'
}
data = {"token": "glados.network"}
res = requests.post(url, headers=headers, data=json.dumps(data))
return json.loads(res.text)['message']
def get_state():
url = 'https://glados.rocks/api/user/status'
headers = {
'cookie': cookie,
'origin': 'https://glados.rocks',
'referer': 'https://glados.rocks/console/checkin',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36'
}
res = requests.get(url, headers=headers)
return str(json.loads(res.text)['data']['leftDays']).split('.')[0]
def send_dingtalk(content):
headers = {
'Content-Type': 'application/json;charset=utf-8'
}
data = {
"msgtype": "text",
"text": {"content": content}
}
res = requests.post(url=webhook, headers=headers, data=json.dumps(data))
print(res.text)
if __name__ == '__main__':
main()
版权属于:吾爱聚合
本文链接:https://blog.5ijh.com/index.php/archives/256/
版权说明:若无注明,本文皆为“吾爱聚合”原创,转载请保留文章出处。
非常好使OωO