-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
385 lines (329 loc) · 15 KB
/
app.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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# -*- coding: utf-8 -*-
from flask import Flask, request
import os
import sqlite3
from threading import Thread
from uuid import uuid4
import requests
import time
from pyquery import PyQuery
import re
import json
app = Flask(__name__)
# 服务
def dg():
print('打工线程启动')
while True:
sql = sqlite3.connect('database.db')
info = sql.execute("SELECT name,cookie,id FROM user").fetchall()
sql.close()
for i in info:
url = 'https://www.tsdm39.com/plugin.php?id=np_cliworkdz:work'
headers = {
'Cookie': i[1],
'User-Agent': 'Mozilla/5.0 (Linux; Android 9.0; SAMSUNG SM-F900U Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36 Edg/111.0.1661.62'
}
for _ in [1, 2, 3, 4, 5, 6, 7]:
while True:
try:
requests.post(url=url, headers=headers, data={'act': 'clickad'})
break
except:
print(i[0], ' 出现异常,正在重试')
sql = sqlite3.connect('database.db')
sql.execute("INSERT INTO task (type, time, info) VALUES (?, ?, ?)",
('dg', str(time.time_ns()), i[0] + ' 出现异常,正在重试',))
sql.commit()
sql.close()
time.sleep(60)
time.sleep(2)
while True:
try:
ttt = requests.post(url=url, headers=headers, data={'act': 'getcre'}).text
break
except:
sql = sqlite3.connect('database.db')
sql.execute("INSERT INTO task (type, time, info) VALUES (?, ?, ?)",
('dg', str(time.time_ns()), i[0] + ' 出现异常,正在重试',))
sql.commit()
sql.close()
print(i[0], ' 出现异常,正在重试')
time.sleep(60)
if '不要作弊哦,重新进行游戏吧' in ttt:
print(i[0], ' 出现作弊')
sql = sqlite3.connect('database.db')
sql.execute("INSERT INTO task (type, time, info) VALUES (?, ?, ?)", ('dg', str(time.time_ns()), i[0] + '出现作弊',))
sql.commit()
sql.close()
info.append(i)
time.sleep(60)
continue
if '必须与上一次间隔6小时0分钟0秒才可再次进行' in ttt:
print(i[0], ' 时间未到')
sql = sqlite3.connect('database.db')
sql.execute("INSERT INTO task (type, time, info) VALUES (?, ?, ?)", ('dg', str(time.time_ns()), i[0] + '时间未到',))
sql.commit()
sql.close()
continue
print(i[0], ' 打工完成')
sql = sqlite3.connect('database.db')
sql.execute("INSERT INTO task (type, time, info) VALUES (?, ?, ?)",
('dg', str(time.time_ns()), i[0] + ' 打工完成',))
sql.commit()
sql.close()
time.sleep(5)
sql = sqlite3.connect('database.db')
sql.execute("INSERT INTO status (type, time, info) VALUES (?, ?, ?)", ('dg', str(time.time_ns()), '打工完成',))
sql.commit()
sql.close()
Thread(target=cx, daemon=True).start()
time.sleep(21600)
def qd():
print('签到线程启动')
while True:
# 获取用户信息
sql = sqlite3.connect('database.db')
info = sql.execute("SELECT name,cookie,id FROM user").fetchall()
sql.close()
for i in info:
# 获取formhash值
url = 'https://www.tsdm39.com/forum.php?mobile=yes'
headers = {
'Cookie': i[1],
'User-Agent': 'Mozilla/5.0 (Linux; Android 9.0; SAMSUNG SM-F900U Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36 Edg/111.0.1661.62'
}
text = ''
while True:
try:
text = requests.get(url=url, headers=headers).text
break
except:
sql = sqlite3.connect('database.db')
sql.execute("INSERT INTO task (type, time, info) VALUES (?, ?, ?)",
('qd', str(time.time_ns()), i[0] + ' 出现异常,正在重试',))
sql.commit()
sql.close()
print(i[0], ' 出现异常,正在重试')
time.sleep(60)
text = text.replace('<?xml version="1.0" encoding="utf-8"?>', '')
doc = PyQuery(text)
t = doc('body > div.wp > div.pd2 > a:nth-child(11)').attr('href')
if t == '':
print(i[0], ' Cookie过期')
sql = sqlite3.connect('database.db')
sql.execute("INSERT INTO task (type, time, info) VALUES (?, ?, ?)",
('qd', str(time.time_ns()), i[0] + 'Cookie过期',))
sql.commit()
sql.close()
continue
formhash = re.search('(?<=(formhash=)).*?(?=(&mobile=yes))', t)[0]
time.sleep(2)
# 进行签到
url = 'https://www.tsdm39.com/plugin.php?id=dsu_paulsign:sign&operation=qiandao&infloat=0&inajax=0&mobile=yes'
headers = {
'Cookie': i[1],
'User-Agent': 'Mozilla/5.0 (Linux; Android 9.0; SAMSUNG SM-F900U Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36 Edg/111.0.1661.62'
}
data = {
'formhash': str(formhash),
'qdxq': 'kx',
'qdmode': '3',
'todaysay': '',
'fastreply': '1'
}
text = ''
con = 0
while True:
try:
text = requests.post(url=url, headers=headers, data=data).text
if '您今日已经签到' in text:
sql = sqlite3.connect('database.db')
sql.execute("INSERT INTO task (type, time, info) VALUES (?, ?, ?)",
('qd', str(time.time_ns()), i[0] + '已经签到',))
sql.commit()
sql.close()
break
if '恭喜你签到成功!获得随机奖励' not in text:
print(i[0], ' 出现未知问题', con)
sql = sqlite3.connect('database.db')
sql.execute("INSERT INTO task (type, time, info) VALUES (?, ?, ?)",
('qd', str(time.time_ns()), i[0] + '出现未知问题,重试:' + str(con),))
sql.commit()
sql.close()
con = con + 1
time.sleep(10)
if con == 3:
sql = sqlite3.connect('database.db')
sql.execute("INSERT INTO task (type, time, info) VALUES (?, ?, ?)",
('qd', str(time.time_ns()), i[0] + '取消重试',))
sql.commit()
sql.close()
con = 0
break
continue
break
except:
sql = sqlite3.connect('database.db')
sql.execute("INSERT INTO task (type, time, info) VALUES (?, ?, ?)",
('qd', str(time.time_ns()), i[0] + ' 出现异常,正在重试',))
sql.commit()
sql.close()
print(i[0], ' 出现异常,正在重试')
time.sleep(60)
text = text.replace('<?xml version="1.0" encoding="utf-8"?>', '')
doc = PyQuery(text)
sql = sqlite3.connect('database.db')
sql.execute("INSERT INTO task (type, time, info) VALUES (?, ?, ?)",
('qd', str(time.time_ns()), i[0] + '获得天使币:' + doc('#messagetext > p:nth-child(1)').text().replace('恭喜你签到成功!获得随机奖励 天使币 ', ''),))
sql.commit()
sql.close()
print(i[0] + '获得天使币:' + doc('#messagetext > p:nth-child(1)').text().replace('恭喜你签到成功!获得随机奖励 天使币 ', ''))
time.sleep(5)
sql = sqlite3.connect('database.db')
sql.execute("INSERT INTO status (type, time, info) VALUES (?, ?, ?)",
('qd', str(time.time_ns()), '签到完成',))
sql.commit()
sql.close()
Thread(target=cx, daemon=True).start()
time.sleep(86460)
def cx():
print('查询线程启动')
while True:
sql = sqlite3.connect('database.db')
info = sql.execute("SELECT name,cookie,id FROM user").fetchall()
sql.close()
for i in info:
url = 'https://www.tsdm39.com/home.php?mod=space&uid=' + i[2] + '&do=profile&mobile=yes'
headers = {
'User-Agent': 'Mozilla/5.0 (Linux; Android 9.0; SAMSUNG SM-F900U Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36 Edg/111.0.1661.62'
}
text = ''
while True:
try:
text = requests.get(url=url, headers=headers).text
break
except:
print(i[0], ' 出现异常,正在重试')
time.sleep(60)
text = text.replace('<?xml version="1.0" encoding="utf-8"?>', '')
doc = PyQuery(text)
sql = sqlite3.connect('database.db')
sql.execute("UPDATE user SET tsb = ? WHERE id = ?",
(str(int(re.search('(?<=(天使币)).*?(?=( ))', doc('body > div.wp > div.bm > div.bm > div > div').text())[0])),i[2],))
sql.commit()
sql.close()
time.sleep(2)
time.sleep(43200)
# 首次启动检查
if os.path.exists('database.db') is False:
open('database.db', 'w').close()
sql = sqlite3.connect('database.db')
sql.execute("create table user (cookie text not null,id text not null,name text not null,tsb text default '0' not null)")
sql.execute("create table task (uuid INTEGER constraint task_pk primary key autoincrement,type text not null,time text not null,info text not null)")
sql.execute("create table status (uuid INTEGER constraint task_pk primary key autoincrement,type text not null,time text not null,info text not null)")
sql.commit()
sql.close()
print('没有数据库,已自动创建')
# 创建服务
Thread(target=dg, daemon=True).start()
Thread(target=qd, daemon=True).start()
pwd = 'L$5V$9eszfv$AX4*&(shajvmtZ&qJQVMT^LNq1lmzwlA%p1CVia3IYO%BV(vCrop'
# 路由
@app.route('/')
def index():
return app.send_static_file('index.html')
@app.route('/index.css')
def indexCSS():
return app.send_static_file('index.css')
@app.route('/index.js')
def indexJS():
return app.send_static_file('index.js')
@app.route('/jquery-3.7.0.js')
def indexJquery():
return app.send_static_file('jquery-3.7.0.js')
@app.route('/login')
def login():
return app.send_static_file('login.html')
@app.route('/api/log/dg', methods=['POST'])
def apiLogDG():
if request.form.get('pwd') != pwd:
return {'code': '0001', 'info': '密码错误'}
sql = sqlite3.connect('database.db')
info = sql.execute("SELECT time,info FROM task WHERE type='dg' ORDER BY uuid DESC LIMIT 0,10").fetchall()
sql.close()
return info
@app.route('/api/log/qd', methods=['POST'])
def apiLogQD():
if request.form.get('pwd') != pwd:
return {'code': '0001', 'info': '密码错误'}
sql = sqlite3.connect('database.db')
info = sql.execute("SELECT time,info FROM task WHERE type='qd' ORDER BY uuid DESC LIMIT 0,10").fetchall()
sql.close()
return info
@app.route('/api/user/add', methods=['POST'])
def apiUserAdd():
if request.form.get('pwd') != pwd:
return {'code': '0001', 'info': '密码错误'}
cookie = request.form.get('cookie')
id = request.form.get('id')
name = request.form.get('name')
if cookie == '' or id == '' or name == '':
return {'code': '0102', 'info': '不能为空'}
sql = sqlite3.connect('database.db')
u = sql.execute("SELECT id FROM user WHERE id=?", (id,)).fetchone()
if u is not None:
return {'code': '0101', 'info': '账户重复'}
sql.execute("INSERT INTO user (cookie, id, name) VALUES (?, ?, ?)", (cookie, id, name,))
sql.commit()
sql.close()
return {'code': '0000', 'info': '添加成功'}
@app.route('/api/user/del', methods=['POST'])
def apiUserDel():
if request.form.get('pwd') != pwd:
return {'code': '0001', 'info': '密码错误'}
id = request.form.get('id')
sql = sqlite3.connect('database.db')
sql.execute("DELETE FROM user WHERE id = ?", (str(id),))
sql.commit()
sql.close()
return {'code': '0000', 'info': '删除成功'}
@app.route('/api/user/all', methods=['POST'])
def apiUserAll():
if request.form.get('pwd') != pwd:
return {'code': '0001', 'info': '密码错误'}
sql = sqlite3.connect('database.db')
info = sql.execute("SELECT id,name,cookie FROM user").fetchall()
if info is None:
return []
sql.close()
return info
@app.route('/api/tsb', methods=['POST'])
def apiTSB():
if request.form.get('pwd') != pwd:
return {'code': '0001', 'info': '密码错误'}
sql = sqlite3.connect('database.db')
info = sql.execute("SELECT tsb FROM user").fetchall()
if info is None:
return '0'
sql.close()
all = 0
for i in info:
all = all + int(i[0])
return str(all)
@app.route('/api/status', methods=['POST'])
def apiStatus():
if request.form.get('pwd') != pwd:
return {'code': '0001', 'info': '密码错误'}
sql = sqlite3.connect('database.db')
try:
dgv = sql.execute("SELECT time FROM status WHERE type='dg' ORDER BY uuid DESC LIMIT 0,1").fetchone()[0]
except:
dgv = '0'
try:
qdv = sql.execute("SELECT time FROM status WHERE type='qd' ORDER BY uuid DESC LIMIT 0,1").fetchone()[0]
except:
qdv = '0'
sql.close()
return {'code': '0000', 'info': '查询成功', 'msg': {'dg': dgv, 'qd': qdv}}
if __name__ == '__main__':
app.run(port=os.getenv("PORT", default=5000), host='0.0.0.0')