Update nodriver_tixcraft.py

master
melia19791012 2024-04-23 21:36:33 +08:00 committed by GitHub
parent cb1d1d2a84
commit 8072620ede
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 33 additions and 21 deletions

View File

@ -1,6 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
#encoding=utf-8 #encoding=utf-8
#執行方式python chrome_tixcraft.py 或 python3 chrome_tixcraft.py
import argparse import argparse
import base64 import base64
import json import json
@ -33,7 +32,7 @@ except Exception as exc:
print(exc) print(exc)
pass pass
CONST_APP_VERSION = "MaxBot (2024.04.09)" CONST_APP_VERSION = "MaxBot (2024.04.10)"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
@ -214,7 +213,8 @@ async def nodriver_check_checkbox(tab, select_query, value='true'):
try: try:
element = await tab.query_selector(select_query) element = await tab.query_selector(select_query)
if element: if element:
await element.apply('function (element) { element.checked='+ value +'; } ') #await element.apply('function (element) { element.checked='+ value +'; } ')
await element.click()
is_checkbox_checked = True is_checkbox_checked = True
except Exception as exc: except Exception as exc:
#print("check checkbox fail for selector:", select_query) #print("check checkbox fail for selector:", select_query)
@ -651,6 +651,9 @@ async def nodriver_kktix_reg_captcha(tab, config_dict, fail_list, registrationsN
inferred_answer_string = answer_item inferred_answer_string = answer_item
break break
if len(answer_list) > 0:
answer_list = list(dict.fromkeys(answer_list))
if show_debug_message: if show_debug_message:
print("inferred_answer_string:", inferred_answer_string) print("inferred_answer_string:", inferred_answer_string)
print("question_text:", question_text) print("question_text:", question_text)
@ -658,6 +661,7 @@ async def nodriver_kktix_reg_captcha(tab, config_dict, fail_list, registrationsN
print("fail_list:", fail_list) print("fail_list:", fail_list)
# PS: auto-focus() when empty inferred_answer_string with empty inputed text value. # PS: auto-focus() when empty inferred_answer_string with empty inputed text value.
if len(inferred_answer_string) > 0:
input_text_css = 'div.custom-captcha-inner > div > div > input' input_text_css = 'div.custom-captcha-inner > div > div > input'
next_step_button_css = '' next_step_button_css = ''
submit_by_enter = False submit_by_enter = False
@ -666,10 +670,19 @@ async def nodriver_kktix_reg_captcha(tab, config_dict, fail_list, registrationsN
if len(answer_list) > 0: if len(answer_list) > 0:
input_text = await tab.query_selector(input_text_css) input_text = await tab.query_selector(input_text_css)
if not input_text is None: if not input_text is None:
await input_text.send_keys(answer_list[0])
await input_text.click()
await input_text.apply('function (element) {element.value = ""; } ')
await input_text.send_keys(inferred_answer_string)
time.sleep(0.1)
# due multi next buttons(pick seats/best seats) # due multi next buttons(pick seats/best seats)
print("click")
await nodriver_kktix_press_next_button(tab) await nodriver_kktix_press_next_button(tab)
time.sleep(0.75)
fail_list.append(inferred_answer_string)
return fail_list, is_question_popup return fail_list, is_question_popup
@ -769,7 +782,7 @@ async def nodriver_kktix_reg_new_main(tab, config_dict, fail_list, played_sound_
play_sound_while_ordering(config_dict) play_sound_while_ordering(config_dict)
played_sound_ticket = True played_sound_ticket = True
is_finish_checkbox_click = await nodriver_check_checkbox(tab, 'input[type="checkbox"]') is_finish_checkbox_click = await nodriver_check_checkbox(tab, 'input[type="checkbox"]:not(:checked)')
# whole event question. # whole event question.
fail_list, is_question_popup = await nodriver_kktix_reg_captcha(tab, config_dict, fail_list, registrationsNewApp_div) fail_list, is_question_popup = await nodriver_kktix_reg_captcha(tab, config_dict, fail_list, registrationsNewApp_div)
@ -1072,7 +1085,7 @@ async def nodriver_tixcraft_input_check_code(tab, config_dict, fail_list, questi
async def nodriver_tixcraft_ticket_main_agree(tab, config_dict): async def nodriver_tixcraft_ticket_main_agree(tab, config_dict):
for i in range(3): for i in range(3):
is_finish_checkbox_click = await nodriver_check_checkbox(tab, '#TicketForm_agree') is_finish_checkbox_click = await nodriver_check_checkbox(tab, '#TicketForm_agree:not(:checked)')
if is_finish_checkbox_click: if is_finish_checkbox_click:
break break
@ -1450,7 +1463,7 @@ async def nodriver_ticketplus_main(tab, url, config_dict, ocr, Captcha_Browser):
async def nodriver_ibon_ticket_agree(tab): async def nodriver_ibon_ticket_agree(tab):
for i in range(3): for i in range(3):
is_finish_checkbox_click = await nodriver_check_checkbox(tab, '#agreen') is_finish_checkbox_click = await nodriver_check_checkbox(tab, '#agreen:not(:checked)')
if is_finish_checkbox_click: if is_finish_checkbox_click:
break break
@ -1481,7 +1494,7 @@ async def nodriver_ibon_main(tab, url, config_dict, ocr, Captcha_Browser):
is_event_page = True is_event_page = True
if is_event_page: if is_event_page:
# ibon auto press signup # ibon auto press signup
await nodriver_press_button('.btn.btn-signup') await nodriver_press_button(tab, '.btn.btn-signup')
is_match_target_feature = False is_match_target_feature = False
@ -1560,7 +1573,7 @@ async def nodriver_ibon_main(tab, url, config_dict, ocr, Captcha_Browser):
if 'PRODUCT_ID=' in url.upper(): if 'PRODUCT_ID=' in url.upper():
# step 1: select area. # step 1: select area.
is_match_target_feature = True is_price_assign_by_bot = False
# TODO: # TODO:
#is_price_assign_by_bot = ibon_performance(driver, config_dict) #is_price_assign_by_bot = ibon_performance(driver, config_dict)
@ -1578,8 +1591,7 @@ async def nodriver_ibon_main(tab, url, config_dict, ocr, Captcha_Browser):
if is_do_ibon_performance_with_ticket_number: if is_do_ibon_performance_with_ticket_number:
if config_dict["advanced"]["disable_adjacent_seat"]: if config_dict["advanced"]["disable_adjacent_seat"]:
# TODO: # TODO:
#is_finish_checkbox_click = ibon_allow_not_adjacent_seat(driver, config_dict) is_finish_checkbox_click = await nodriver_check_checkbox(tab, '.asp-checkbox > input[type="checkbox"]:not(:checked)')
pass
# captcha # captcha
is_captcha_sent = False is_captcha_sent = False