Skip to content
This repository was archived by the owner on Jun 27, 2025. It is now read-only.

Commit 453ad94

Browse files
authored
Add files via upload
1 parent 5d65ce4 commit 453ad94

File tree

1 file changed

+43
-40
lines changed

1 file changed

+43
-40
lines changed

main.py

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -176,36 +176,12 @@ def process_thread(ticketid,cookie_str):
176176
return True
177177
else:
178178
while i < 2:
179-
with open(f"output_ticket_{ticketid}_{ids_str}_attempt_{i}.txt", "a") as output_file:
180-
output_file.write(resp)
181-
retn_params = sign_for_post(ticketid)
182-
url = 'https://www.allcpp.cn/allcpp/ticket/buyTicketAliWapPay.do?ticketTypeId=' + str(ticketid) + '&count=' + str(
183-
id_count) + '&' + retn_params +'&purchaserIds=' + ids_str
184-
print(url)
185-
response = requests.post(
186-
url=url,
187-
cookies=cookies,
188-
headers=headers,
189-
json=json_data,
190-
)
191-
resp = response.content.decode("utf-8")
192-
parsed_resp = json.loads(resp)
193-
print(parsed_resp)
194-
is_success = parsed_resp["isSuccess"]
195-
if is_success == True:
196-
i = 3
197-
print(f"Thread for ticket {ticketid} succeeded")
198-
with open(f"output_ticket_{ticketid}_{ids_str}.txt", "a") as output_file:
179+
try:
180+
with open(f"output_ticket_{ticketid}_{ids_str}_attempt_{i}.txt", "a") as output_file:
199181
output_file.write(resp)
200-
threads_to_close = [thread for thread in threads if thread._target == process_thread and thread._args[0] == ticketid and thread._args[1] == cookies]
201-
for thread_to_close in threads_to_close[:2]: # 关闭同类型的前两个线程
202-
thread_to_close.join()
203-
return True
204-
else:
205-
with open(f"output_ticket_{ticketid}_{ids_str}_attempt.txt", "a") as output_file:
206-
output_file.write(resp)
207-
url = 'https://www.allcpp.cn/allcpp/ticket/buyTicketAliWapPay.do?ticketTypeId=' + str(ticketid) + '&count=' + str(
208-
id_count) + '&' + retn_params +'&purchaserIds=' + ids_str
182+
retn_params = sign_for_post(ticketid)
183+
url = 'https://www.allcpp.cn/allcpp/ticket/buyTicketAliWapPay.do?ticketTypeId=' + str(ticketid) + '&count=' + str(
184+
id_count) + '&' + retn_params +'&purchaserIds=' + ids_str
209185
print(url)
210186
response = requests.post(
211187
url=url,
@@ -215,22 +191,49 @@ def process_thread(ticketid,cookie_str):
215191
)
216192
resp = response.content.decode("utf-8")
217193
parsed_resp = json.loads(resp)
194+
print(parsed_resp)
218195
is_success = parsed_resp["isSuccess"]
219196
if is_success == True:
220-
i = 3
221-
print(f"Thread for ticket {ticketid} succeeded")
222-
with open(f"output_ticket_{ticketid}_{ids_str}.txt", "a") as output_file:
223-
output_file.write(resp)
224-
threads_to_close = [thread for thread in threads if thread._target == process_thread and thread._args[0] == ticketid and thread._args[1] == cookies]
225-
for thread_to_close in threads_to_close[:2]: # 关闭同类型的前两个线程
226-
thread_to_close.join()
227-
return True
197+
i = 3
198+
print(f"Thread for ticket {ticketid} succeeded")
199+
with open(f"output_ticket_{ticketid}_{ids_str}.txt", "a") as output_file:
200+
output_file.write(resp)
201+
threads_to_close = [thread for thread in threads if thread._target == process_thread and thread._args[0] == ticketid and thread._args[1] == cookies]
202+
for thread_to_close in threads_to_close[:2]: # 关闭同类型的前两个线程
203+
thread_to_close.join()
204+
return True
228205
else:
229206
with open(f"output_ticket_{ticketid}_{ids_str}_attempt.txt", "a") as output_file:
230207
output_file.write(resp)
231-
print(resp)
232-
print(type(resp))
233-
time.sleep(sleep_time)
208+
url = 'https://www.allcpp.cn/allcpp/ticket/buyTicketAliWapPay.do?ticketTypeId=' + str(ticketid) + '&count=' + str(
209+
id_count) + '&' + retn_params +'&purchaserIds=' + ids_str
210+
print(url)
211+
response = requests.post(
212+
url=url,
213+
cookies=cookies,
214+
headers=headers,
215+
json=json_data,
216+
)
217+
resp = response.content.decode("utf-8")
218+
parsed_resp = json.loads(resp)
219+
is_success = parsed_resp["isSuccess"]
220+
if is_success == True:
221+
i = 3
222+
print(f"Thread for ticket {ticketid} succeeded")
223+
with open(f"output_ticket_{ticketid}_{ids_str}.txt", "a") as output_file:
224+
output_file.write(resp)
225+
threads_to_close = [thread for thread in threads if thread._target == process_thread and thread._args[0] == ticketid and thread._args[1] == cookies]
226+
for thread_to_close in threads_to_close[:2]: # 关闭同类型的前两个线程
227+
thread_to_close.join()
228+
return True
229+
else:
230+
with open(f"output_ticket_{ticketid}_{ids_str}_attempt.txt", "a") as output_file:
231+
output_file.write(resp)
232+
print(resp)
233+
print(type(resp))
234+
time.sleep(sleep_time)
235+
except:
236+
pass
234237

235238

236239
def start(cookies, ticket_ids):

0 commit comments

Comments
 (0)