-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnext.py
92 lines (72 loc) · 2.53 KB
/
next.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
#ZYGLQexplorer/RainYun-Checkin
import requests
import json
"""请求IPIP并原样返回"""
def get_base_ip(*,log_func = print):
log_func('获取网络状态...')
return requests.request("GET", "https://myip.ipip.net/").text.strip()
"""请求用户信息"""
def get_user_info(api_key,*,entry_point="https://api.v2.rainyun.com/user/",log_func = print):
headers = {
'X-Api-Key': api_key
}
payload={}
log_func('获取用户信息...')
response = requests.request("GET", entry_point, headers=headers, data=payload).json()
return response
"""签到"""
def checkin(api_key,*,entry_point='https://api.v2.rainyun.com/user/reward/tasks',log_func = print):
headers = {
'content-type':"application/json",
'X-Api-Key':api_key
}
payload = {
"task_name" : '每日签到'
}
log_func('发送每日签到...')
response = requests.request("POST", entry_point, headers=headers, data = json.dumps(payload)).json()
return response
#初始化全局变量
api_keys = [] #placeholder
api_key = '' #placeholder
succeed = 0
duplicate = 0
failed = 0
#获取机密
with open("arguments.txt") as f:
api_keys = f.read().strip().split(',')
assert api_keys
print('==============================')
print(get_base_ip())
for i,api_key in enumerate(api_keys,start=1):
# api_key = api_keys[0]
print('==============================')
print(f'任务第 {i} 项,共 {len(api_keys)} 项')
print(f'APIKEY的长度是 {len(api_key)}')
info_before = get_user_info(api_key)
points_before = info_before['data']['Points']
ID = info_before['data']['ID']
name = info_before['data']['Name']
#print(f'ID: {ID}')
print(f'用户名: {name[0]}***{name[-1]}')
print(f'签到前积分: {points_before}')
checkin_response = checkin(api_key)
info_after =get_user_info(api_key)
points_after = info_after['data']['Points']
print(f'签到后积分: {points_after}')
if points_after > points_before :
print(f'返回值: {checkin_response}')
print('鉴定为签到成功')
succeed += 1
elif checkin_response['code'] == 30011:
print(f'返回值: {checkin_response}')
print('鉴定为签到重复')
duplicate += 1
else:
print(f'返回值: {checkin_response}')
print('鉴定为签到失败')
failed += 1
print('==============================')
print("全部任务已完成")
print(f"成功{succeed}个,重复签到{duplicate}个,失败{failed}个")
assert succeed or duplicate