auto reload for kham/ticket.com.tw

master
Max 2023-11-17 12:03:07 +08:00 committed by GitHub
parent 720ea3980d
commit 275d0eb106
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 130 additions and 114 deletions

View File

@ -55,7 +55,7 @@ import webbrowser
import chromedriver_autoinstaller import chromedriver_autoinstaller
CONST_APP_VERSION = "MaxBot (2023.11.13)" CONST_APP_VERSION = "MaxBot (2023.11.14)"
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"
@ -9599,12 +9599,12 @@ def hkam_date_auto_select(driver, domain_name, config_dict):
date_keyword = config_dict["tixcraft"]["date_auto_select"]["date_keyword"].strip() date_keyword = config_dict["tixcraft"]["date_auto_select"]["date_keyword"].strip()
auto_reload_coming_soon_page_enable = config_dict["tixcraft"]["auto_reload_coming_soon_page"] auto_reload_coming_soon_page_enable = config_dict["tixcraft"]["auto_reload_coming_soon_page"]
ret = False if show_debug_message:
print("date_keyword:", date_keyword)
print("auto_reload_coming_soon_page_enable:", auto_reload_coming_soon_page_enable)
matched_blocks = None matched_blocks = None
# default not selected.
is_date_assigned = False
if not is_date_assigned:
area_list = None area_list = None
try: try:
# for kham.com # for kham.com
@ -9712,7 +9712,9 @@ def hkam_date_auto_select(driver, domain_name, config_dict):
pass pass
target_area = get_target_item_from_matched_list(matched_blocks, auto_select_mode) target_area = get_target_item_from_matched_list(matched_blocks, auto_select_mode)
is_date_assign_by_bot = False
if not target_area is None: if not target_area is None:
is_button_clicked = False
el_btn = None el_btn = None
try: try:
my_css_selector = "button" my_css_selector = "button"
@ -9725,18 +9727,32 @@ def hkam_date_auto_select(driver, domain_name, config_dict):
if el_btn.is_enabled() and el_btn.is_displayed(): if el_btn.is_enabled() and el_btn.is_displayed():
el_btn.click() el_btn.click()
print("buy button pressed.") print("buy button pressed.")
ret = True is_button_clicked = True
except Exception as exc: except Exception as exc:
# use plan B # use plan B
try: try:
print("force to click by js.") print("force to click by js.")
driver.execute_script("arguments[0].click();", el_btn) driver.execute_script("arguments[0].click();", el_btn)
ret = True is_button_clicked = True
except Exception as exc:
pass
is_date_assign_by_bot = is_button_clicked
else:
# no target to click.
if auto_reload_coming_soon_page_enable:
# auto refresh for date list page.
if not formated_area_list is None:
if len(formated_area_list) == 0:
try:
driver.refresh()
time.sleep(0.3)
except Exception as exc: except Exception as exc:
pass pass
if config_dict["advanced"]["auto_reload_random_delay"]:
time.sleep(random.randint(0,CONST_AUTO_RELOAD_RANDOM_DELAY_MAX_SECOND))
return ret return is_date_assign_by_bot
def kham_product(driver, domain_name, config_dict): def kham_product(driver, domain_name, config_dict):
show_debug_message = True # debug. show_debug_message = True # debug.