update for kktix / ticketplus.
parent
55ffe16fdb
commit
7b5c3f3057
|
@ -55,7 +55,7 @@ import webbrowser
|
||||||
|
|
||||||
import chromedriver_autoinstaller
|
import chromedriver_autoinstaller
|
||||||
|
|
||||||
CONST_APP_VERSION = "MaxBot (2023.11.23)"
|
CONST_APP_VERSION = "MaxBot (2023.12.01)"
|
||||||
|
|
||||||
CONST_MAXBOT_CONFIG_FILE = "settings.json"
|
CONST_MAXBOT_CONFIG_FILE = "settings.json"
|
||||||
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
|
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
|
||||||
|
@ -222,10 +222,14 @@ def write_string_to_file(filename, data):
|
||||||
outfile.write("%s" % data)
|
outfile.write("%s" % data)
|
||||||
|
|
||||||
def write_question_to_file(question_text):
|
def write_question_to_file(question_text):
|
||||||
write_string_to_file(CONST_MAXBOT_QUESTION_FILE, question_text)
|
working_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
target_path = os.path.join(working_dir, CONST_MAXBOT_QUESTION_FILE)
|
||||||
|
write_string_to_file(target_path, question_text)
|
||||||
|
|
||||||
def write_last_url_to_file(url):
|
def write_last_url_to_file(url):
|
||||||
write_string_to_file(CONST_MAXBOT_LAST_URL_FILE, url)
|
working_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
target_path = os.path.join(working_dir, CONST_MAXBOT_LAST_URL_FILE)
|
||||||
|
write_string_to_file(target_path, url)
|
||||||
|
|
||||||
def read_last_url_from_file():
|
def read_last_url_from_file():
|
||||||
ret = ""
|
ret = ""
|
||||||
|
@ -244,6 +248,25 @@ def format_keyword_string(keyword):
|
||||||
keyword = keyword.replace(' ','').lower()
|
keyword = keyword.replace(' ','').lower()
|
||||||
return keyword
|
return keyword
|
||||||
|
|
||||||
|
def format_quota_string(formated_html_text):
|
||||||
|
formated_html_text = formated_html_text.replace('「','【')
|
||||||
|
formated_html_text = formated_html_text.replace('〔','【')
|
||||||
|
formated_html_text = formated_html_text.replace('[','【')
|
||||||
|
formated_html_text = formated_html_text.replace('〖','【')
|
||||||
|
formated_html_text = formated_html_text.replace('[','【')
|
||||||
|
formated_html_text = formated_html_text.replace('(','【')
|
||||||
|
formated_html_text = formated_html_text.replace('(','【')
|
||||||
|
|
||||||
|
formated_html_text = formated_html_text.replace('」','】')
|
||||||
|
formated_html_text = formated_html_text.replace('〕','】')
|
||||||
|
formated_html_text = formated_html_text.replace(']','】')
|
||||||
|
formated_html_text = formated_html_text.replace('〗','】')
|
||||||
|
formated_html_text = formated_html_text.replace(']','】')
|
||||||
|
formated_html_text = formated_html_text.replace(')','】')
|
||||||
|
formated_html_text = formated_html_text.replace(')','】')
|
||||||
|
return formated_html_text
|
||||||
|
|
||||||
|
|
||||||
def full2half(keyword):
|
def full2half(keyword):
|
||||||
n = ""
|
n = ""
|
||||||
if not keyword is None:
|
if not keyword is None:
|
||||||
|
@ -908,12 +931,14 @@ def get_driver_by_config(config_dict):
|
||||||
|
|
||||||
# common functions.
|
# common functions.
|
||||||
def find_between( s, first, last ):
|
def find_between( s, first, last ):
|
||||||
|
ret = ""
|
||||||
try:
|
try:
|
||||||
start = s.index( first ) + len( first )
|
start = s.index( first ) + len( first )
|
||||||
end = s.index( last, start )
|
end = s.index( last, start )
|
||||||
return s[start:end]
|
ret = s[start:end]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return ""
|
pass
|
||||||
|
return ret
|
||||||
|
|
||||||
# convert web string to reg pattern
|
# convert web string to reg pattern
|
||||||
def convert_string_to_pattern(my_str, dynamic_length=True):
|
def convert_string_to_pattern(my_str, dynamic_length=True):
|
||||||
|
@ -2637,17 +2662,7 @@ def guess_tixcraft_question(driver, question_text):
|
||||||
if len(question_text) > 0:
|
if len(question_text) > 0:
|
||||||
# format question text.
|
# format question text.
|
||||||
formated_html_text = question_text
|
formated_html_text = question_text
|
||||||
formated_html_text = formated_html_text.replace('「','【')
|
formated_html_text = format_quota_string(formated_html_text)
|
||||||
formated_html_text = formated_html_text.replace('〔','【')
|
|
||||||
formated_html_text = formated_html_text.replace('[','【')
|
|
||||||
formated_html_text = formated_html_text.replace('〖','【')
|
|
||||||
formated_html_text = formated_html_text.replace('[','【')
|
|
||||||
|
|
||||||
formated_html_text = formated_html_text.replace('」','】')
|
|
||||||
formated_html_text = formated_html_text.replace('〕','】')
|
|
||||||
formated_html_text = formated_html_text.replace(']','】')
|
|
||||||
formated_html_text = formated_html_text.replace('〗','】')
|
|
||||||
formated_html_text = formated_html_text.replace(']','】')
|
|
||||||
|
|
||||||
if '【' in formated_html_text and '】' in formated_html_text:
|
if '【' in formated_html_text and '】' in formated_html_text:
|
||||||
# PS: 這個太容易沖突,因為問題類型太多,不能直接使用。
|
# PS: 這個太容易沖突,因為問題類型太多,不能直接使用。
|
||||||
|
@ -4283,7 +4298,7 @@ def get_answer_list_from_question_string(registrationsNewApp_div, captcha_text_d
|
||||||
is_use_quota_message = False
|
is_use_quota_message = False
|
||||||
if "「" in captcha_text_div_text and "」" in captcha_text_div_text:
|
if "「" in captcha_text_div_text and "」" in captcha_text_div_text:
|
||||||
# test for rule#1, it's seem very easy conflict...
|
# test for rule#1, it's seem very easy conflict...
|
||||||
match_quota_text_items = ["下方","空白","輸入","引號","文字"]
|
match_quota_text_items = ["空白","輸入","引號","文字"]
|
||||||
is_match_quota_text = True
|
is_match_quota_text = True
|
||||||
for each_quota_text in match_quota_text_items:
|
for each_quota_text in match_quota_text_items:
|
||||||
if not each_quota_text in captcha_text_div_text:
|
if not each_quota_text in captcha_text_div_text:
|
||||||
|
@ -4292,9 +4307,26 @@ def get_answer_list_from_question_string(registrationsNewApp_div, captcha_text_d
|
||||||
is_use_quota_message = True
|
is_use_quota_message = True
|
||||||
#print("is_use_quota_message:" , is_use_quota_message)
|
#print("is_use_quota_message:" , is_use_quota_message)
|
||||||
if is_use_quota_message:
|
if is_use_quota_message:
|
||||||
inferred_answer_string = find_between(captcha_text_div_text, "「", "」")
|
temp_answer = find_between(captcha_text_div_text, "「", "」")
|
||||||
|
if len(temp_answer) > 0:
|
||||||
|
inferred_answer_string = temp_answer
|
||||||
#print("find captcha text:" , inferred_answer_string)
|
#print("find captcha text:" , inferred_answer_string)
|
||||||
|
|
||||||
|
# 請在下方空白處輸入括號內數字
|
||||||
|
if inferred_answer_string is None:
|
||||||
|
formated_html_text = captcha_text_div_text.strip()
|
||||||
|
formated_html_text = format_quota_string(formated_html_text)
|
||||||
|
formated_html_text = formated_html_text.replace('的','')
|
||||||
|
formated_html_text = formated_html_text.replace('之內','內')
|
||||||
|
match_quota_text_items = ["輸入括號內數字","輸入括號內文字","輸入括號內文數字"
|
||||||
|
,"輸入引號內數字","輸入引號內文字","輸入引號內文數字"]
|
||||||
|
if len(formated_html_text) <= 30:
|
||||||
|
if not '\n' in formated_html_text:
|
||||||
|
if '【' in formated_html_text and '】' in formated_html_text:
|
||||||
|
temp_answer = find_between(formated_html_text, "【", "】")
|
||||||
|
if len(temp_answer) > 0:
|
||||||
|
inferred_answer_string = temp_answer
|
||||||
|
|
||||||
if inferred_answer_string is None:
|
if inferred_answer_string is None:
|
||||||
is_use_quota_message = False
|
is_use_quota_message = False
|
||||||
if "【" in captcha_text_div_text and "】" in captcha_text_div_text:
|
if "【" in captcha_text_div_text and "】" in captcha_text_div_text:
|
||||||
|
@ -6775,22 +6807,28 @@ def assign_text(driver, by, query, val, overwrite = False, submit=False, overwri
|
||||||
is_do_keyin = True
|
is_do_keyin = True
|
||||||
|
|
||||||
if is_do_keyin:
|
if is_do_keyin:
|
||||||
builder = ActionChains(driver)
|
if len(inputed_text) > 0:
|
||||||
builder.move_to_element(el_text)
|
builder = ActionChains(driver)
|
||||||
builder.click(el_text)
|
builder.move_to_element(el_text)
|
||||||
if platform.system() == 'Darwin':
|
builder.click(el_text)
|
||||||
builder.key_down(Keys.COMMAND)
|
if platform.system() == 'Darwin':
|
||||||
|
builder.key_down(Keys.COMMAND)
|
||||||
|
else:
|
||||||
|
builder.key_down(Keys.CONTROL)
|
||||||
|
builder.send_keys("a")
|
||||||
|
if platform.system() == 'Darwin':
|
||||||
|
builder.key_up(Keys.COMMAND)
|
||||||
|
else:
|
||||||
|
builder.key_up(Keys.CONTROL)
|
||||||
|
builder.send_keys(val)
|
||||||
|
if submit:
|
||||||
|
builder.send_keys(Keys.ENTER)
|
||||||
|
builder.perform()
|
||||||
else:
|
else:
|
||||||
builder.key_down(Keys.CONTROL)
|
el_text.click()
|
||||||
builder.send_keys("a")
|
el_text.send_keys(val)
|
||||||
if platform.system() == 'Darwin':
|
if submit:
|
||||||
builder.key_up(Keys.COMMAND)
|
el_text.send_keys(Keys.ENTER)
|
||||||
else:
|
|
||||||
builder.key_up(Keys.CONTROL)
|
|
||||||
builder.send_keys(val)
|
|
||||||
if submit:
|
|
||||||
builder.send_keys(Keys.ENTER)
|
|
||||||
builder.perform()
|
|
||||||
is_text_sent = True
|
is_text_sent = True
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
if show_debug_message:
|
if show_debug_message:
|
||||||
|
@ -7242,10 +7280,14 @@ def check_pop_alert(driver):
|
||||||
def list_all_cookies(driver):
|
def list_all_cookies(driver):
|
||||||
cookies_dict = {}
|
cookies_dict = {}
|
||||||
if not driver is None:
|
if not driver is None:
|
||||||
all_cookies=driver.get_cookies();
|
try:
|
||||||
for cookie in all_cookies:
|
all_cookies=driver.get_cookies();
|
||||||
cookies_dict[cookie['name']] = cookie['value']
|
for cookie in all_cookies:
|
||||||
print(cookies_dict)
|
cookies_dict[cookie['name']] = cookie['value']
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
return cookies_dict
|
||||||
|
#print(cookies_dict)
|
||||||
|
|
||||||
def set_non_browser_cookies(driver, url, Captcha_Browser):
|
def set_non_browser_cookies(driver, url, Captcha_Browser):
|
||||||
if not driver is None:
|
if not driver is None:
|
||||||
|
@ -11542,16 +11584,30 @@ def ticketplus_keyin_captcha_code(driver, answer = "", auto_submit = False):
|
||||||
def ticketplus_account_auto_fill(driver, config_dict):
|
def ticketplus_account_auto_fill(driver, config_dict):
|
||||||
# auto fill account info.
|
# auto fill account info.
|
||||||
if len(config_dict["advanced"]["ticketplus_account"]) > 0:
|
if len(config_dict["advanced"]["ticketplus_account"]) > 0:
|
||||||
sign_in_btn = None
|
is_user_signin = False
|
||||||
try:
|
try:
|
||||||
my_css_selector = 'button.v-btn > span.v-btn__content > i.mdi-account'
|
all_cookies=list_all_cookies(driver)
|
||||||
sign_in_btn = driver.find_element(By.CSS_SELECTOR, my_css_selector)
|
if 'user' in all_cookies:
|
||||||
if not sign_in_btn is None:
|
#print('user in cookie')
|
||||||
sign_in_btn.click()
|
if '%22account%22:%22' in all_cookies['user']:
|
||||||
time.sleep(0.2)
|
#print('user:', all_cookies['user'])
|
||||||
|
is_user_signin = True
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
print(exc)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
#print("is_user_signin:", is_user_signin)
|
||||||
|
if not is_user_signin:
|
||||||
|
sign_in_btn = None
|
||||||
|
try:
|
||||||
|
my_css_selector = 'button.v-btn > span.v-btn__content > i.mdi-account'
|
||||||
|
sign_in_btn = driver.find_element(By.CSS_SELECTOR, my_css_selector)
|
||||||
|
if not sign_in_btn is None:
|
||||||
|
sign_in_btn.click()
|
||||||
|
time.sleep(0.2)
|
||||||
|
except Exception as exc:
|
||||||
|
pass
|
||||||
|
|
||||||
# manually keyin verify code.
|
# manually keyin verify code.
|
||||||
form_account = None
|
form_account = None
|
||||||
try:
|
try:
|
||||||
|
@ -12052,6 +12108,7 @@ def test_captcha_model():
|
||||||
captcha_text_div_text = "請回答下列問題,請在下方空格輸入DELIGHT(請以半形輸入法作答,大小寫需要一模一樣)"
|
captcha_text_div_text = "請回答下列問題,請在下方空格輸入DELIGHT(請以半形輸入法作答,大小寫需要一模一樣)"
|
||||||
#captcha_text_div_text = "請在下方空白處輸入引號內文字:「abc」"
|
#captcha_text_div_text = "請在下方空白處輸入引號內文字:「abc」"
|
||||||
#captcha_text_div_text = "請在下方空白處輸入引號內文字:「0118eveconcert」(請以半形小寫作答。)"
|
#captcha_text_div_text = "請在下方空白處輸入引號內文字:「0118eveconcert」(請以半形小寫作答。)"
|
||||||
|
#captcha_text_div_text = "請在下方空白處輸入括號內數字(1234)"
|
||||||
#captcha_text_div_text = "在《DEEP AWAKENING見過深淵的人》專輯中,哪一首為合唱曲目? 【V6】深淵 、【Z5】浮木、【J8】無聲、【C1】以上皆非 (請以半形輸入法作答,大小寫/阿拉伯數字需要一模一樣,範例:A2)"
|
#captcha_text_div_text = "在《DEEP AWAKENING見過深淵的人》專輯中,哪一首為合唱曲目? 【V6】深淵 、【Z5】浮木、【J8】無聲、【C1】以上皆非 (請以半形輸入法作答,大小寫/阿拉伯數字需要一模一樣,範例:A2)"
|
||||||
#captcha_text_div_text = "Super Junior 的隊長是以下哪位? 【v】神童 【w】藝聲 【x】利特 【y】始源 若你覺得答案為 a,請輸入 a (英文為半形小寫)"
|
#captcha_text_div_text = "Super Junior 的隊長是以下哪位? 【v】神童 【w】藝聲 【x】利特 【y】始源 若你覺得答案為 a,請輸入 a (英文為半形小寫)"
|
||||||
#captcha_text_div_text = "請問XXX, 請以英文為半形小寫(例如:a) a. 1月5日 b. 2月5日 c. 3月5日 d. 4月5日"
|
#captcha_text_div_text = "請問XXX, 請以英文為半形小寫(例如:a) a. 1月5日 b. 2月5日 c. 3月5日 d. 4月5日"
|
||||||
|
|
Loading…
Reference in New Issue