2023-02-19, fix tixcraft single answer not always retry.
parent
cc97bfe937
commit
3eb61d254a
|
@ -50,7 +50,7 @@ except Exception as exc:
|
|||
import ssl
|
||||
ssl._create_default_https_context = ssl._create_unverified_context
|
||||
|
||||
CONST_APP_VERSION = u"MaxBot (2023.02.18)"
|
||||
CONST_APP_VERSION = u"MaxBot (2023.02.19)"
|
||||
|
||||
CONST_HOMEPAGE_DEFAULT = "https://tixcraft.com"
|
||||
URL_GOOGLE_OAUTH = 'https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&prompt=consent&response_type=code&client_id=407408718192.apps.googleusercontent.com&scope=email&access_type=offline&flowName=GeneralOAuthFlow'
|
||||
|
@ -1710,7 +1710,11 @@ def tixcraft_ticket_number_auto_fill(driver, select_obj, ticket_number):
|
|||
return is_ticket_number_assigned
|
||||
|
||||
def guess_tixcraft_question(driver):
|
||||
show_debug_message = True # debug.
|
||||
show_debug_message = False # online
|
||||
|
||||
inferred_answer_string = None
|
||||
answer_list = []
|
||||
|
||||
form_select = None
|
||||
try:
|
||||
|
@ -1726,47 +1730,51 @@ def guess_tixcraft_question(driver):
|
|||
except Exception as exc:
|
||||
print("get text fail")
|
||||
|
||||
html_text = ""
|
||||
formated_html_text = ""
|
||||
if question_text is not None:
|
||||
if len(question_text) > 0:
|
||||
# format question text.
|
||||
html_text = question_text
|
||||
html_text = html_text.replace(u'「',u'【')
|
||||
html_text = html_text.replace(u'〔',u'【')
|
||||
html_text = html_text.replace(u'[',u'【')
|
||||
html_text = html_text.replace(u'〖',u'【')
|
||||
html_text = html_text.replace(u'[',u'【')
|
||||
formated_html_text = question_text
|
||||
formated_html_text = formated_html_text.replace(u'「',u'【')
|
||||
formated_html_text = formated_html_text.replace(u'〔',u'【')
|
||||
formated_html_text = formated_html_text.replace(u'[',u'【')
|
||||
formated_html_text = formated_html_text.replace(u'〖',u'【')
|
||||
formated_html_text = formated_html_text.replace(u'[',u'【')
|
||||
|
||||
html_text = html_text.replace(u'」',u'】')
|
||||
html_text = html_text.replace(u'〕',u'】')
|
||||
html_text = html_text.replace(u']',u'】')
|
||||
html_text = html_text.replace(u'〗',u'】')
|
||||
html_text = html_text.replace(u']',u'】')
|
||||
formated_html_text = formated_html_text.replace(u'」',u'】')
|
||||
formated_html_text = formated_html_text.replace(u'〕',u'】')
|
||||
formated_html_text = formated_html_text.replace(u']',u'】')
|
||||
formated_html_text = formated_html_text.replace(u'〗',u'】')
|
||||
formated_html_text = formated_html_text.replace(u']',u'】')
|
||||
|
||||
if u'【' in html_text and u'】' in html_text:
|
||||
if u'【' in formated_html_text and u'】' in formated_html_text:
|
||||
# PS: 這個太容易沖突,因為問題類型太多,不能直接使用。
|
||||
#inferred_answer_string = find_between(html_text, u"【", u"】")
|
||||
#inferred_answer_string = find_between(formated_html_text, u"【", u"】")
|
||||
pass
|
||||
|
||||
if show_debug_message:
|
||||
print("html_text:", html_text)
|
||||
print("formated_html_text:", formated_html_text)
|
||||
|
||||
is_options_in_question = False
|
||||
|
||||
# 請輸入"YES",代表您已詳閱且瞭解並同意。
|
||||
if inferred_answer_string is None:
|
||||
if u'輸入"YES"' in html_text:
|
||||
if u'已詳閱' in html_text or '請詳閱' in html_text:
|
||||
if u'同意' in html_text:
|
||||
if u'輸入"YES"' in formated_html_text:
|
||||
if u'已詳閱' in formated_html_text or '請詳閱' in formated_html_text:
|
||||
if u'同意' in formated_html_text:
|
||||
inferred_answer_string = 'YES'
|
||||
|
||||
# 購票前請詳閱注意事項,並於驗證碼欄位輸入【同意】繼續購票流程。
|
||||
if inferred_answer_string is None:
|
||||
if '驗證碼' in html_text or '驗證欄位' in html_text:
|
||||
if '已詳閱' in html_text or '請詳閱' in html_text:
|
||||
if '輸入【同意】' in html_text:
|
||||
if '驗證碼' in formated_html_text or '驗證欄位' in formated_html_text:
|
||||
if '已詳閱' in formated_html_text or '請詳閱' in formated_html_text:
|
||||
if '輸入【同意】' in formated_html_text:
|
||||
inferred_answer_string = '同意'
|
||||
return inferred_answer_string
|
||||
|
||||
if inferred_answer_string is None:
|
||||
inferred_answer_string, answer_list = get_answer_list_from_question_string(None, question_text)
|
||||
|
||||
return inferred_answer_string, answer_list
|
||||
|
||||
def tixcraft_verify(driver, presale_code, presale_code_delimiter, answer_index):
|
||||
show_debug_message = True # debug.
|
||||
|
@ -1774,21 +1782,34 @@ def tixcraft_verify(driver, presale_code, presale_code_delimiter, answer_index):
|
|||
|
||||
inferred_answer_string = None
|
||||
answer_list = []
|
||||
if len(presale_code) > 0:
|
||||
inferred_answer_string = presale_code
|
||||
|
||||
is_retry_user_single_answer = False
|
||||
|
||||
if len(presale_code) > 0:
|
||||
if len(presale_code_delimiter) > 0:
|
||||
if presale_code_delimiter in presale_code:
|
||||
answer_list = presale_code.split(presale_code_delimiter)
|
||||
if len(answer_list) > 0:
|
||||
if answer_index < len(answer_list)-1:
|
||||
inferred_answer_string = answer_list[answer_index+1]
|
||||
else:
|
||||
is_retry_user_single_answer = True
|
||||
if answer_index < 2:
|
||||
inferred_answer_string = presale_code
|
||||
|
||||
if inferred_answer_string is None:
|
||||
inferred_answer_string = guess_tixcraft_question(driver)
|
||||
inferred_answer_string, answer_list = guess_tixcraft_question(driver)
|
||||
if inferred_answer_string is None:
|
||||
if not answer_list is None:
|
||||
if len(answer_list) > 0:
|
||||
if answer_index < len(answer_list)-1:
|
||||
inferred_answer_string = answer_list[answer_index+1]
|
||||
|
||||
if show_debug_message:
|
||||
print("answer_index:", answer_index)
|
||||
print("inferred_answer_string:", inferred_answer_string)
|
||||
print("answer_index:", answer_index)
|
||||
print("is_retry_user_single_answer:", is_retry_user_single_answer)
|
||||
|
||||
form_input = None
|
||||
try:
|
||||
|
@ -1819,8 +1840,7 @@ def tixcraft_verify(driver, presale_code, presale_code_delimiter, answer_index):
|
|||
is_password_sent = True
|
||||
|
||||
# guess answer mode.
|
||||
if len(presale_code_delimiter) > 0:
|
||||
answer_index += 1
|
||||
answer_index += 1
|
||||
|
||||
if show_debug_message:
|
||||
print("sent password by bot:", inferred_answer_string)
|
||||
|
@ -1836,8 +1856,11 @@ def tixcraft_verify(driver, presale_code, presale_code_delimiter, answer_index):
|
|||
except Exception as exc:
|
||||
pass
|
||||
|
||||
# guess answer mode.
|
||||
if len(presale_code_delimiter) > 0:
|
||||
if is_retry_user_single_answer:
|
||||
# increase counter for waiting for stop retry.
|
||||
answer_index += 1
|
||||
else:
|
||||
# guess answer mode.
|
||||
if answer_index > -1:
|
||||
# here not is first option.
|
||||
inferred_answer_previous = None
|
||||
|
@ -5571,7 +5594,7 @@ def check_pop_alert(driver):
|
|||
|
||||
if is_match_auto_close_text:
|
||||
alert.accept()
|
||||
print("alert3 accepted")
|
||||
#print("alert3 accepted")
|
||||
|
||||
is_alert_popup = True
|
||||
else:
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "pass_1_seat_remaining": true, "auto_check_agree": true, "ocr_captcha": {"enable": true, "force_submit": false, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "area_mode": "from top to bottom", "area_keyword_1": "", "area_keyword_1_and": "", "area_keyword_2": "", "area_keyword_2_and": "", "area_keyword_2_enable": true, "auto_guess_options": true, "user_guess_string": ""}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "from top to bottom"}, "area_auto_select": {"enable": true, "area_keyword_1": "", "area_keyword_2": "", "area_keyword_3": "", "area_keyword_4": "", "area_keyword_2_enable": true, "area_keyword_3_enable": true, "area_keyword_4_enable": true, "mode": "from top to bottom"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true, "presale_code": ""}, "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "facebook_account": "", "kktix_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "facebook_password": "", "kktix_password": "", "cityline_password": "", "urbtix_password": "", "hkticketing_password": "", "kham_password": "", "adblock_plus_enable": false, "open_google_oauth_url": false}, "debug": false}
|
||||
{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "pass_1_seat_remaining": true, "auto_check_agree": true, "ocr_captcha": {"enable": true, "force_submit": false, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "area_mode": "from top to bottom", "area_keyword_1": "", "area_keyword_1_and": "", "area_keyword_2": "", "area_keyword_2_and": "", "area_keyword_2_enable": true, "auto_guess_options": true, "user_guess_string": ""}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "from top to bottom"}, "area_auto_select": {"enable": true, "area_keyword_1": "", "area_keyword_2": "", "area_keyword_3": "", "area_keyword_4": "", "area_keyword_2_enable": true, "area_keyword_3_enable": true, "area_keyword_4_enable": true, "mode": "from top to bottom"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true, "presale_code": "", "presale_code_delimiter": ""}, "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "facebook_account": "", "kktix_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "facebook_password": "", "kktix_password": "", "cityline_password": "", "urbtix_password": "", "hkticketing_password": "", "kham_password": "", "adblock_plus_enable": false, "open_google_oauth_url": false}, "debug": false}
|
|
@ -20,7 +20,7 @@ import webbrowser
|
|||
import pyperclip
|
||||
import base64
|
||||
|
||||
CONST_APP_VERSION = u"MaxBot (2023.02.18)"
|
||||
CONST_APP_VERSION = u"MaxBot (2023.02.19)"
|
||||
|
||||
CONST_FROM_TOP_TO_BOTTOM = u"from top to bottom"
|
||||
CONST_FROM_BOTTOM_TO_TOP = u"from bottom to top"
|
||||
|
|
Loading…
Reference in New Issue