-
Notifications
You must be signed in to change notification settings - Fork 1
/
miao_ql_api.py
107 lines (74 loc) · 3.14 KB
/
miao_ql_api.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
# 青龙内网端口
from miao_config import *
import urllib.parse
from jd_mysql import get_wxid_bypin
class ql_api():
def __init__(self):
self.url = ql_url
self.headers =ql_headers
def login(self):
data = '{"username":"%s","password":"%s"}' % (username, password)
response = requests.post(f'http://{self.url}/api/user/login',
headers=self.headers, data=data, verify=False)
print(response.text)
def dele_re_task(self,task_id):
data =f'["{task_id}"]'
requests.delete(f'http://{self.url}/api/crons',
headers=self.headers, data=data,
verify=False)
def get_task(self):
response = requests.get(f'http://{self.url}/api/crons',
headers=self.headers, verify=False)
data = json.loads(response.text)
li = []
for a in range(data['data']['total']):
all_task = data['data']['data'][a]['command']
li.append(all_task)
# print(li)
id_li = []
for b in range(data['data']['total']):
all_task_id = data['data']['data'][b]['id']
id_li.append(all_task_id)
# print(id_li)
# 任务列表和id列表是一一对应的~Å
news_li = []
for index, i in enumerate(li):
if i not in news_li:
news_li.append(i)
else:
# 通找到对应id进行删除
self.dele_re_task(id_li[index])
# 进行去重操作~
print('去重后所的任务数量为' + str(len(news_li)) + "个")
def check_ck(self):
data = self.get_status()
for a in range(len((data['data']))):
status = data['data'][a]['status']
if status == 1:
ck = data['data'][a]['value']
print(ck)
pin = re.findall('pt_pin=(.*);',ck)[0]
#这里找到的是中文的编码
chinese_pin = urllib.parse.unquote(pin)
result = get_wxid_bypin(pin)
if result:
send_text_msg(result, '你这个'+chinese_pin+'失效\n请再次登陆京东\n回复「教学」查看上车教学\n重新登陆即可\n输入「查询」查看总上车情况')
time.sleep(15)
def get_status(self):
params = (
('searchValue', ''),
)
response = requests.get(f'http://{self.url}/api/envs', headers=self.headers, params=params, verify=False)
data = json.loads(response.text)
return data
def delete_ck(self):
data = self.get_status()
for a in range(len(data['data'])):
if data['data'][a]['status'] == 1:
id = data['data'][a]['id']
print(id)
data = f'["{id}"]'
response = requests.delete(f'http://{self.url}/api/envs',
headers=self.headers, data=data,
verify=False)
print(response.text)