-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathcheckIn_RRShiPin.py
228 lines (209 loc) · 7.98 KB
/
checkIn_RRShiPin.py
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
'''
new Env('人人视频日常')
cron: 0 9 * * *
Author: BNDou
Date: 2024-06-05 01:56:28
LastEditTime: 2024-08-03 20:56:45
FilePath: \Auto_Check_In\checkIn_RRShiPin.py
抓包流程:
①开启抓包,打开签到页
②找到url = https://api.qwdjapp.com/activity/index/integral 的请求头
③分别复制 clientVersion clientType token aliId st 四个值,写到环境变量中,格式如下:
环境变量名为 COOKIE_RRShiPin 多账户用 回车 或 && 分开
clientVersion=xxx; clientType=xxx; token=xxx; aliId=xxx; st=xxx;
'''
import os
import re
import sys
import requests
# 测试用环境变量
# os.environ['COOKIE_RRShiPin'] = ''
try: # 异常捕捉
from utils.notify import send # 导入消息通知模块
except Exception as err: # 异常捕捉
print('%s\n🔴加载通知服务失败~' % err)
# 获取环境变量
def get_env():
# 判断 COOKIE_RRShiPin 是否存在于环境变量
if "COOKIE_RRShiPin" in os.environ:
# 读取系统变量以 \n 或 && 分割变量
cookie_list = re.split('\n|&&', os.environ.get('COOKIE_RRShiPin'))
else:
# 标准日志输出
print('🔴未添加 COOKIE_RRShiPin 变量')
send('人人视频日常', '🔴未添加 COOKIE_RRShiPin 变量')
# 脚本退出
sys.exit(0)
return cookie_list
class RRShiPin:
'''
Quark类封装了积分查询、签到任务列表查询、签到、激活任务、领取任务奖励的方法
'''
def __init__(self, cookie):
'''
初始化方法
:param cookie: 用户登录后的cookie,用于后续的请求
'''
self.cookie = {
a.split('=')[0]: a.split('=')[1]
for a in cookie.replace(" ", "").split(';') if a != ''
}
def user_information(self):
'''
获取用户信息
:return: 返回用户信息
'''
url = f"https://api.qwdjapp.com/user/personal/information?token={self.cookie.get('token')}"
headers = {
"clientVersion": self.cookie.get('clientVersion'),
"clientType": self.cookie.get('clientType'),
"token": self.cookie.get('token'),
"aliId": self.cookie.get('aliId'),
"st": self.cookie.get('st'),
}
rjson = requests.get(url, headers=headers).json()
if rjson['code'] == '0000':
self.cookie['nickName'] = rjson['data']['user']['nickName']
return f"👶 登录账号: {rjson['data']['user']['nickName']}"
return f"🔴 登录账号: 失败\n{rjson}"
def get_integral(self):
'''
获取用户当前的积分信息
:return: 返回用户当前的积分信息
'''
url = "https://api.qwdjapp.com/activity/index/integral"
headers = {
"clientVersion": self.cookie.get('clientVersion'),
"clientType": self.cookie.get('clientType'),
"token": self.cookie.get('token'),
"aliId": self.cookie.get('aliId'),
"st": self.cookie.get('st'),
}
rjson = requests.get(url, headers=headers).json()
if rjson['code'] == '0000':
if not rjson['data'] == None:
return rjson['data']['integral']
return f"🔴 获取积分信息失败: \n{rjson}"
def get_sign(self):
'''
请求签到
:return: 返回签到信息
'''
url = "https://api.qwdjapp.com/activity/sign"
headers = {
"clientVersion": self.cookie.get('clientVersion'),
"clientType": self.cookie.get('clientType'),
"token": self.cookie.get('token'),
"aliId": self.cookie.get('aliId'),
"st": self.cookie.get('st'),
}
data = {"sectionId": "0"}
rjson = requests.post(url, headers=headers, data=data).json()
if rjson['code'] == '0000':
if not rjson['data'] == None:
return f"🟢 领取签到奖励: {rjson['data']['value']}"
else:
return '🟢 领取签到奖励: 今日签到奖励已领取!'
return f"🔴 签到失败: \n{rjson}"
def get_list(self):
'''
请求签到任务列表
:return: 返回签到任务列表
'''
url = 'https://api.qwdjapp.com/activity/index/list'
headers = {
"clientVersion": self.cookie.get('clientVersion'),
"clientType": self.cookie.get('clientType'),
"token": self.cookie.get('token'),
"aliId": self.cookie.get('aliId'),
"st": self.cookie.get('st'),
}
rjson = requests.get(url, headers=headers).json()
if rjson['code'] == '0000':
if not rjson['data'] == None:
dailyTaskList = rjson['data']['dailyTaskDto']
if len(dailyTaskList):
dailyTaskList = sorted(dailyTaskList,
key=lambda x: x['id'])
return dailyTaskList
return []
def get_receive(self, taskId):
'''
激活任务
:param taskId: 任务ID
:return: 返回激活任务信息
'''
url = 'https://api.qwdjapp.com/activity/task/status/receive'
headers = {
"clientVersion": self.cookie.get('clientVersion'),
"clientType": self.cookie.get('clientType'),
"token": self.cookie.get('token'),
"aliId": self.cookie.get('aliId'),
"st": self.cookie.get('st'),
}
data = {'taskId': taskId}
rjson = requests.post(url, headers=headers, data=data).json()
if rjson['code'] == '0000':
return f"🟢 任务{taskId}: 激活成功"
return f"🔴 任务{taskId}: 激活失败\n{rjson}"
def get_complete(self, taskId):
'''
领取任务奖励
:param taskId: 任务ID
:return: 返回领取奖励信息
'''
url = "https://api.qwdjapp.com/activity/task/status/complete"
headers = {
"clientVersion": self.cookie.get('clientVersion'),
"clientType": self.cookie.get('clientType'),
"token": self.cookie.get('token'),
"aliId": self.cookie.get('aliId'),
"st": self.cookie.get('st'),
}
data = {"taskId": taskId}
rjson = requests.post(url, headers=headers, data=data).json()
if rjson['code'] == '0000':
return f"🟢 任务{taskId}: 奖励领取成功"
return f"🔴 任务{taskId}: 奖励领取失败\n{rjson}"
def sendLog(self, msg, log):
'''
添加推送日志
:param msg: 消息内容
:param log: 日志内容
:return: 无
'''
print(log)
return (msg + log + "\n")
def run(self):
'''
执行日常任务
:return: 返回一个字符串,包含签到结果
'''
# 获取用户信息
msg = self.sendLog("", self.user_information())
# 获取初始积分信息
print(f"🏅 初始积分: {self.get_integral()}")
# 请求签到
msg = self.sendLog(msg, self.get_sign())
# 获取签到任务列表
dailyTaskList = self.get_list()
# 激活任务和领取奖励
for task in dailyTaskList:
print(f"💠 任务{task['id']}: {task['taskName']} 奖励: {task['count']}")
# 激活任务
print(self.get_receive(task['id']))
# 领取奖励
msg = self.sendLog(msg, self.get_complete(task['id']))
# 获取最终积分信息
msg = self.sendLog(msg, f"🏅 总积分: {self.get_integral()}\n")
return msg
if __name__ == "__main__":
print("----------人人视频开始尝试日常----------")
msg = ""
for cookie_rrshipin in get_env():
msg += f"{RRShiPin(cookie_rrshipin).run()}"
print("----------人人视频日常执行完毕----------")
try:
send('人人视频日常', msg)
except Exception as err:
print('%s\n🔴 错误,请查看运行日志!' % err)