2022-10-21, kktix add second keyword field.

master
CHUN YU YAO 2022-10-21 21:18:07 +08:00
parent 7f5d37aa87
commit ad2d2de1c3
3 changed files with 102 additions and 95 deletions

View File

@ -67,7 +67,7 @@ ssl._create_default_https_context = ssl._create_unverified_context
#附註1沒有寫的很好很多地方應該可以模組化。 #附註1沒有寫的很好很多地方應該可以模組化。
#附註2 #附註2
CONST_APP_VERSION = u"MaxBot (2022.10.20)" CONST_APP_VERSION = u"MaxBot (2022.10.21)"
CONST_FROM_TOP_TO_BOTTOM = u"from top to bottom" CONST_FROM_TOP_TO_BOTTOM = u"from top to bottom"
CONST_FROM_BOTTOM_TO_TOP = u"from bottom to top" CONST_FROM_BOTTOM_TO_TOP = u"from bottom to top"
@ -108,6 +108,7 @@ auto_reload_coming_soon_page_enable = True # default checked.
kktix_area_auto_select_mode = None kktix_area_auto_select_mode = None
kktix_area_keyword = None kktix_area_keyword = None
kktix_date_keyword = None
kktix_answer_dictionary = None kktix_answer_dictionary = None
kktix_answer_dictionary_list = None kktix_answer_dictionary_list = None
@ -148,6 +149,7 @@ def load_config_from_local(driver):
global auto_fill_ticket_number global auto_fill_ticket_number
global kktix_area_auto_select_mode global kktix_area_auto_select_mode
global kktix_area_keyword global kktix_area_keyword
global kktix_date_keyword
global kktix_answer_dictionary global kktix_answer_dictionary
global kktix_answer_dictionary_list global kktix_answer_dictionary_list
@ -209,6 +211,12 @@ def load_config_from_local(driver):
kktix_area_keyword = "" kktix_area_keyword = ""
kktix_area_keyword = kktix_area_keyword.strip() kktix_area_keyword = kktix_area_keyword.strip()
if 'date_keyword' in config_dict["kktix"]:
kktix_date_keyword = config_dict["kktix"]["date_keyword"]
if kktix_date_keyword is None:
kktix_date_keyword = ""
kktix_date_keyword = kktix_date_keyword.strip()
# disable password brute force attack # disable password brute force attack
if 'answer_dictionary' in config_dict["kktix"]: if 'answer_dictionary' in config_dict["kktix"]:
kktix_answer_dictionary = config_dict["kktix"]["answer_dictionary"] kktix_answer_dictionary = config_dict["kktix"]["answer_dictionary"]
@ -281,6 +289,7 @@ def load_config_from_local(driver):
print("auto_press_next_step_button", auto_press_next_step_button) print("auto_press_next_step_button", auto_press_next_step_button)
print("auto_fill_ticket_number", auto_fill_ticket_number) print("auto_fill_ticket_number", auto_fill_ticket_number)
print("kktix_area_keyword", kktix_area_keyword) print("kktix_area_keyword", kktix_area_keyword)
print("kktix_date_keyword", kktix_date_keyword)
print("kktix_answer_dictionary", kktix_answer_dictionary) print("kktix_answer_dictionary", kktix_answer_dictionary)
print("auto_guess_options", auto_guess_options) print("auto_guess_options", auto_guess_options)
@ -1638,17 +1647,20 @@ def kktix_input_captcha_text(captcha_inner_div, captcha_password_string, force_o
return ret return ret
def kktix_assign_ticket_number(driver, ticket_number, kktix_area_keyword): def kktix_assign_ticket_number(driver, ticket_number, kktix_area_keyword, kktix_date_keyword):
ret = False ret = False
areas = None areas = None
ticket_price_list = None
is_ticket_number_assigened = False is_ticket_number_assigened = False
ticket_price_list = None
try: try:
ticket_price_list = driver.find_elements(By.CSS_SELECTOR, '.display-table-row') ticket_price_list = driver.find_elements(By.CSS_SELECTOR, '.display-table-row')
except Exception as exc:
print("find ticket-price span Exception:")
print(exc)
pass
if ticket_price_list is not None: if ticket_price_list is not None:
if len(ticket_price_list) > 0: if len(ticket_price_list) > 0:
areas = [] areas = []
@ -1682,6 +1694,10 @@ def kktix_assign_ticket_number(driver, ticket_number, kktix_area_keyword):
else: else:
# match keyword. # match keyword.
if kktix_area_keyword in row_text: if kktix_area_keyword in row_text:
if len(kktix_date_keyword) == 0:
areas.append(row)
else:
if kktix_date_keyword in row_text:
areas.append(row) areas.append(row)
else: else:
#disabled. #disabled.
@ -1694,10 +1710,6 @@ def kktix_assign_ticket_number(driver, ticket_number, kktix_area_keyword):
else: else:
print("find ticket-price span fail") print("find ticket-price span fail")
except Exception as exc:
print("find ticket-price span Exception:")
print(exc)
pass
if is_ticket_number_assigened: if is_ticket_number_assigened:
ret = True ret = True
@ -1904,7 +1916,7 @@ def kktix_check_register_status(url):
#print("registerStatus:", registerStatus) #print("registerStatus:", registerStatus)
return registerStatus return registerStatus
def kktix_reg_new_main(url, answer_index, registrationsNewApp_div, is_finish_checkbox_click, auto_fill_ticket_number, ticket_number, kktix_area_keyword): def kktix_reg_new_main(url, answer_index, registrationsNewApp_div, is_finish_checkbox_click, auto_fill_ticket_number, ticket_number, kktix_area_keyword, kktix_date_keyword):
show_debug_message = True # debug. show_debug_message = True # debug.
#show_debug_message = False # online #show_debug_message = False # online
@ -1914,7 +1926,7 @@ def kktix_reg_new_main(url, answer_index, registrationsNewApp_div, is_finish_che
is_assign_ticket_number = False is_assign_ticket_number = False
if auto_fill_ticket_number: if auto_fill_ticket_number:
for retry_index in range(10): for retry_index in range(10):
is_assign_ticket_number = kktix_assign_ticket_number(driver, ticket_number, kktix_area_keyword) is_assign_ticket_number = kktix_assign_ticket_number(driver, ticket_number, kktix_area_keyword, kktix_date_keyword)
if is_assign_ticket_number: if is_assign_ticket_number:
break break
#print('is_assign_ticket_number:', is_assign_ticket_number) #print('is_assign_ticket_number:', is_assign_ticket_number)
@ -2432,42 +2444,6 @@ def kktix_reg_new(driver, url, answer_index, kktix_register_status_last):
if not is_need_refresh: if not is_need_refresh:
try: try:
registrationsNewApp_div = driver.find_element(By.CSS_SELECTOR, '#registrationsNewApp') registrationsNewApp_div = driver.find_element(By.CSS_SELECTOR, '#registrationsNewApp')
# old method, disable this block.
'''
if registrationsNewApp_div is not None:
#print("found registrationsNewApp")
el_list = registrationsNewApp_div.find_elements(By.CSS_SELECTOR, "input[type='text']")
if el_list is None:
#print("query input[type='text'] return None")
is_need_refresh = True
else:
#print("found input")
if len(el_list) == 0:
#print("query input[type='text'] length zero")
is_need_refresh = True
else:
is_all_input_disable = True
idx = 0
for el in el_list:
idx += 1
if el.is_enabled():
is_all_input_disable = False
else:
# check value
input_value = str(el.get_attribute('value'))
#print("ticker(%d) number value is:'%s'" % (idx,input_value))
if input_value.strip() != '0':
#print("found not zero value, do not refresh!")
is_all_input_disable = False
if is_all_input_disable:
#print("found all input hidden")
is_need_refresh = True
else:
pass
#print("not found registrationsNewApp")
'''
except Exception as exc: except Exception as exc:
pass pass
#print("find input fail:", exc) #print("find input fail:", exc)
@ -2487,7 +2463,8 @@ def kktix_reg_new(driver, url, answer_index, kktix_register_status_last):
global auto_fill_ticket_number global auto_fill_ticket_number
global ticket_number global ticket_number
global kktix_area_keyword global kktix_area_keyword
answer_index = kktix_reg_new_main(url, answer_index, registrationsNewApp_div, is_finish_checkbox_click, auto_fill_ticket_number, ticket_number, kktix_area_keyword) global kktix_date_keyword
answer_index = kktix_reg_new_main(url, answer_index, registrationsNewApp_div, is_finish_checkbox_click, auto_fill_ticket_number, ticket_number, kktix_area_keyword, kktix_date_keyword)
return answer_index, registerStatus return answer_index, registerStatus
@ -2830,7 +2807,7 @@ def urbtix_ticket_number_auto_select(driver, url, ticket_number):
# True: area block appear. # True: area block appear.
# False: area block not appear. # False: area block not appear.
# ps: return value for date auto select. # ps: return value for date auto select.
def urbtix_area_auto_select(driver, url, kktix_area_keyword): def urbtix_area_auto_select(driver, url, kktix_area_keyword, kktix_date_keyword):
ret = False ret = False
areas = None areas = None
@ -2941,10 +2918,11 @@ def urbtix_performance(driver, url):
global ticket_number global ticket_number
global kktix_area_keyword global kktix_area_keyword
global kktix_date_keyword
global auto_press_next_step_button global auto_press_next_step_button
if auto_fill_ticket_number: if auto_fill_ticket_number:
area_div_exist = urbtix_area_auto_select(driver, url, kktix_area_keyword) area_div_exist = urbtix_area_auto_select(driver, url, kktix_area_keyword, kktix_date_keyword)
ticket_number_select_exist, is_assign_ticket_number = urbtix_ticket_number_auto_select(driver, url, ticket_number) ticket_number_select_exist, is_assign_ticket_number = urbtix_ticket_number_auto_select(driver, url, ticket_number)
@ -2958,7 +2936,7 @@ def urbtix_performance(driver, url):
# True: area block appear. # True: area block appear.
# False: area block not appear. # False: area block not appear.
# ps: return value for date auto select. # ps: return value for date auto select.
def cityline_area_auto_select(url): def cityline_area_auto_select(url, kktix_area_keyword):
ret = False ret = False
areas = None areas = None
@ -3259,7 +3237,7 @@ def cityline_performance(driver, url):
if auto_fill_ticket_number: if auto_fill_ticket_number:
area_div_exist = False area_div_exist = False
if len(kktix_area_keyword) > 0: if len(kktix_area_keyword) > 0:
area_div_exist = cityline_area_auto_select(url) area_div_exist = cityline_area_auto_select(url, kktix_area_keyword)
ticket_number_select_exist, is_assign_ticket_number = cityline_ticket_number_auto_select(url) ticket_number_select_exist, is_assign_ticket_number = cityline_ticket_number_auto_select(url)

View File

@ -1 +1 @@
{"tixcraft": {"pass_1_seat_remaining": true, "area_auto_select": {"area_keyword_1": "", "enable": true, "mode": "from top to bottom", "area_keyword_2": "", "area_keyword": ""}, "date_auto_select": {"enable": true, "date_keyword": "", "mode": "from top to bottom"}}, "homepage1": "https://kktix.com", "homepage2": "https://tixcraft.com", "facebook_account": "", "browser1": "chrome", "browser2": "firefox", "kktix": {"auto_fill_ticket_price": "$1,500", "auto_guess_options": true, "answer_dictionary": "", "area_keyword": "", "auto_press_next_step_button": true, "auto_fill_ticket_number": true, "area_mode": "random"}, "ticket_number": 2, "homepage": "https://tixcraft.com", "browser": "chrome"} {"tixcraft": {"pass_1_seat_remaining": true, "area_auto_select": {"mode": "from top to bottom", "enable": true, "area_keyword_1": "", "area_keyword_2": "", "area_keyword": ""}, "auto_reload_coming_soon_page": true, "date_auto_select": {"enable": true, "date_keyword": "", "mode": "from top to bottom"}, "pass_date_is_sold_out": false}, "homepage1": "https://kktix.com", "homepage2": "https://tixcraft.com", "debug": false, "facebook_account": "", "browser1": "chrome", "browser2": "firefox", "kktix": {"auto_guess_options": true, "auto_fill_ticket_price": "$1,500", "answer_dictionary": "", "area_keyword": "", "auto_press_next_step_button": true, "auto_fill_ticket_number": true, "area_mode": "random", "date_keyword": ""}, "ticket_number": 2, "homepage": "https://kktix.com", "browser": "chrome"}

View File

@ -19,7 +19,7 @@ import sys
import platform import platform
import json import json
CONST_APP_VERSION = u"MaxBot (2022.10.20)" CONST_APP_VERSION = u"MaxBot (2022.10.21)"
CONST_FROM_TOP_TO_BOTTOM = u"from top to bottom" CONST_FROM_TOP_TO_BOTTOM = u"from top to bottom"
CONST_FROM_BOTTOM_TO_TOP = u"from bottom to top" CONST_FROM_BOTTOM_TO_TOP = u"from bottom to top"
@ -75,6 +75,7 @@ def btn_save_act(slience_mode=False):
global chk_state_auto_press_next_step_button global chk_state_auto_press_next_step_button
global chk_state_auto_fill_ticket_number global chk_state_auto_fill_ticket_number
global txt_kktix_area_keyword global txt_kktix_area_keyword
global txt_kktix_date_keyword
# disable password brute force attack # disable password brute force attack
global txt_kktix_answer_dictionary global txt_kktix_answer_dictionary
@ -125,6 +126,7 @@ def btn_save_act(slience_mode=False):
config_dict["kktix"]["auto_fill_ticket_number"] = bool(chk_state_auto_fill_ticket_number.get()) config_dict["kktix"]["auto_fill_ticket_number"] = bool(chk_state_auto_fill_ticket_number.get())
config_dict["kktix"]["area_mode"] = combo_kktix_area_mode.get().strip() config_dict["kktix"]["area_mode"] = combo_kktix_area_mode.get().strip()
config_dict["kktix"]["area_keyword"] = txt_kktix_area_keyword.get().strip() config_dict["kktix"]["area_keyword"] = txt_kktix_area_keyword.get().strip()
config_dict["kktix"]["date_keyword"] = txt_kktix_date_keyword.get().strip()
# disable password brute force attack # disable password brute force attack
#config_dict["kktix"]["answer_dictionary"] = txt_kktix_answer_dictionary.get().strip() #config_dict["kktix"]["answer_dictionary"] = txt_kktix_answer_dictionary.get().strip()
config_dict["kktix"]["auto_guess_options"] = bool(chk_state_auto_guess_options.get()) config_dict["kktix"]["auto_guess_options"] = bool(chk_state_auto_guess_options.get())
@ -382,6 +384,7 @@ def MainMenu(root):
kktix_area_mode = "" kktix_area_mode = ""
kktix_area_keyword = "" kktix_area_keyword = ""
kktix_date_keyword = ""
# disable password brute force attack # disable password brute force attack
#kktix_answer_dictionary = "" #kktix_answer_dictionary = ""
auto_guess_options = False # default not checked. auto_guess_options = False # default not checked.
@ -440,6 +443,12 @@ def MainMenu(root):
kktix_area_keyword = "" kktix_area_keyword = ""
kktix_area_keyword = kktix_area_keyword.strip() kktix_area_keyword = kktix_area_keyword.strip()
if 'date_keyword' in config_dict["kktix"]:
kktix_date_keyword = config_dict["kktix"]["date_keyword"]
if kktix_date_keyword is None:
kktix_date_keyword = ""
kktix_date_keyword = kktix_date_keyword.strip()
if 'auto_guess_options' in config_dict["kktix"]: if 'auto_guess_options' in config_dict["kktix"]:
auto_guess_options = config_dict["kktix"]["auto_guess_options"] auto_guess_options = config_dict["kktix"]["auto_guess_options"]
@ -510,6 +519,7 @@ def MainMenu(root):
print("auto_fill_ticket_number", auto_fill_ticket_number) print("auto_fill_ticket_number", auto_fill_ticket_number)
print("kktix_area_mode", kktix_area_mode) print("kktix_area_mode", kktix_area_mode)
print("kktix_area_keyword", kktix_area_keyword) print("kktix_area_keyword", kktix_area_keyword)
print("kktix_date_keyword", kktix_date_keyword)
# disable password brute force attack # disable password brute force attack
#print("kktix_answer_dictionary", kktix_answer_dictionary) #print("kktix_answer_dictionary", kktix_answer_dictionary)
print("auto_guess_options", auto_guess_options) print("auto_guess_options", auto_guess_options)
@ -663,6 +673,25 @@ def MainMenu(root):
txt_kktix_area_keyword = Entry(frame_group_kktix, width=20, textvariable = txt_kktix_area_keyword_value) txt_kktix_area_keyword = Entry(frame_group_kktix, width=20, textvariable = txt_kktix_area_keyword_value)
txt_kktix_area_keyword.grid(column=1, row=group_row_count, sticky = W) txt_kktix_area_keyword.grid(column=1, row=group_row_count, sticky = W)
group_row_count+=1
lbl_kktix_area_keyword_and_label = Label(frame_group_kktix, text="")
lbl_kktix_area_keyword_and_label.grid(column=0, row=group_row_count, sticky = E)
lbl_kktix_area_keyword_and_text = Label(frame_group_kktix, text="And")
lbl_kktix_area_keyword_and_text.grid(column=1, row=group_row_count, sticky = W)
group_row_count+=1
lbl_kktix_date_keyword = Label(frame_group_kktix, text="")
lbl_kktix_date_keyword.grid(column=0, row=group_row_count, sticky = E)
global txt_kktix_date_keyword
global txt_kktix_date_keyword_value
txt_kktix_date_keyword_value = StringVar(frame_group_kktix, value=kktix_date_keyword)
txt_kktix_date_keyword = Entry(frame_group_kktix, width=20, textvariable = txt_kktix_date_keyword_value)
txt_kktix_date_keyword.grid(column=1, row=group_row_count, sticky = W)
#group_row_count+=1 #group_row_count+=1
# disable password brute force attack # disable password brute force attack