-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCheckin.py
More file actions
100 lines (92 loc) · 4.07 KB
/
Checkin.py
File metadata and controls
100 lines (92 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# coding:utf-8
import sys
import requests
from requests.exceptions import SSLError
import random
import time
import json
import datetime
'''
需要自行更改的变量:
cookie:登陆glados网页后账号对应的cookie,经两周的测试,同账号对应的cookie不会改变。
将koa:sess和koa:sess.sig填入sess和sig即可,或者复制相同格式的cookie直接赋值给cookie也可。
serverkey:通过server酱脚本可以将运行结果发到微信上,便于查看。如不需要使用,可将serverEn设为0.
serverEn:是否启用server酱上报结果,1启用,0关闭。
'''
sess = '' # cookie中koa:sess的值
sig = '' # cookie中koa:sess.sig的值
cookie = 'koa:sess={0}; koa:sess.sig={1}'.format(sess, sig) # 也可直接复制相同格式的cookie 即cookie = '你的cookie'
serverkey = '请输入server酱的key'
serverEn = 1
def dailyCheckin():
url = 'https://glados.rocks/api/user/checkin' # glados网站签到使用的url
headers = {
"accept": "application/json, text/plain, */*",
"content-type": "application/json;charset=UTF-8",
"sec-ch-ua-platform": "\"Windows\"",
"cookie": "{0}".format(cookie), # cookie需要自行填写
'User-Agent': 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36',
}
data = {
"token": "glados.network"
}
global result
try:
response = session.post(url, headers=headers, json=data)
except SSLError: # 为避免开启系统代理后无法成功链接出现错误,这里尝试使用代理重新链接。
session.proxies = proxies
response = session.post(url, headers=headers, json=data, proxies=proxies)
# print(response.text)
dict = json.loads(response.text) # 获取返回的信息,其中message还有结果信息
if 'Checkin' in dict['message']:
result = 1
elif 'Tomorrow' in dict['message']:
result = -1
print(dict['message'])
print(response.status_code)
return response.status_code
def WechatSend(title, desp, key):
url = 'https://sctapi.ftqq.com/{0}.send'.format(key) # server酱使用的url,key需自行填写
headers = {
"Content-type": "application/x-www-form-urlencoded"
}
data = {
"title": "{0}".format(title), # 传给微信的标题
"desp": "{0}".format(desp) # 传给微信的内容
}
try:
response = requests.post(url, headers=headers, params=data)
except SSLError:
response = requests.post(url, headers=headers, params=data, proxies=proxies)
# print(response.text)
dict = json.loads(response.text)
print(dict['data'])
print(response.status_code)
if __name__ == '__main__':
time1 = datetime.datetime.now()
print('====='+str(time1)+'=====')
random_time = random.random() * 360
print(random_time)
time.sleep(random_time) # 做一个简单时间随机,虽然glados应该没有机器人签到的限制,大概没什么意义。。
result = 0
session = requests.session()
proxies = {'http': '127.0.0.1:7890', # clash默认的代理,为避免打开clash后脚本无法正确访问互联网,在出现问题后尝试用代理访问。如需要使用其他代理,可在这里同步更改。
'https': '127.0.0.1:7890'}
retcode = dailyCheckin() # 签到
if(serverEn == 0): # 如不需要server酱上报,输出结果。
print('返回代码为'+retcode+'运行结果为:'+result)
sys.exit(0)
if(retcode != 200):
title = '签到错误'
desp = '发送签到POST时未得到200相应'
elif result == 1 :
title = '签到成功'
desp = 'Checkin!'
elif result == 0:
title = '签到失败'
desp = '得到回复但未回复Checkin!或Try Tomorrow,请自行确认是否成功签到'
elif result == -1:
title = '重复签到'
desp = '今天已签到过,try tomorrow'
WechatSend(title, desp, serverkey)
sys.exit(0)