2023-09-14, update for ticket.com.tw

master
CHUN YU YAO 2023-10-10 11:55:30 +08:00
parent ad316dd221
commit 9644837664
4 changed files with 24 additions and 12 deletions

View File

@ -55,7 +55,7 @@ import webbrowser
import chromedriver_autoinstaller import chromedriver_autoinstaller
CONST_APP_VERSION = "MaxBot (2023.09.13)" CONST_APP_VERSION = "MaxBot (2023.09.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"
@ -9843,10 +9843,10 @@ def ticket_performance_ticket_number(driver, config_dict):
form_input = None form_input = None
try: try:
form_input = driver.find_element(By.CSS_SELECTOR, 'input[type="text"][value="0"]') form_input = driver.find_element(By.CSS_SELECTOR, 'div.qty-select input[type="text"]')
except Exception as exc: except Exception as exc:
if show_debug_message: if show_debug_message:
print("find #AMOUNT fail") print("find qty-select input fail")
print(exc) print(exc)
pass pass
@ -9877,8 +9877,7 @@ def ticket_performance_ticket_number(driver, config_dict):
is_ticket_number_assigned = True is_ticket_number_assigned = True
except Exception as exc: except Exception as exc:
try: try:
print("force to click by js.") driver.execute_script("arguments[0].value='"+ str(ticket_number) +"'';", form_input)
driver.execute_script("arguments[0].click();", el_div)
ret = True ret = True
except Exception as exc: except Exception as exc:
pass pass
@ -10369,7 +10368,10 @@ def kham_main(driver, url, config_dict, ocr, Captcha_Browser):
is_ticket_number_assigned = kham_performance_ticket_number(driver, config_dict) is_ticket_number_assigned = kham_performance_ticket_number(driver, config_dict)
if config_dict["advanced"]["disable_adjacent_seat"]: if config_dict["advanced"]["disable_adjacent_seat"]:
is_finish_checkbox_click = ticket_allow_not_adjacent_seat(driver, config_dict) if "ticket.com.tw" in url:
is_finish_checkbox_click = ticket_allow_not_adjacent_seat(driver, config_dict)
else:
is_finish_checkbox_click = kham_allow_not_adjacent_seat(driver, config_dict)
if show_debug_message: if show_debug_message:
print("is_ticket_number_assigned:", is_ticket_number_assigned) print("is_ticket_number_assigned:", is_ticket_number_assigned)
@ -10409,19 +10411,29 @@ def kham_main(driver, url, config_dict, ocr, Captcha_Browser):
is_captcha_sent = kham_captcha(driver, config_dict, ocr, Captcha_Browser, model_name) is_captcha_sent = kham_captcha(driver, config_dict, ocr, Captcha_Browser, model_name)
if config_dict["advanced"]["disable_adjacent_seat"]: if config_dict["advanced"]["disable_adjacent_seat"]:
is_finish_checkbox_click = kham_allow_not_adjacent_seat(driver, config_dict) if "ticket.com.tw" in url:
is_finish_checkbox_click = ticket_allow_not_adjacent_seat(driver, config_dict)
else:
is_finish_checkbox_click = kham_allow_not_adjacent_seat(driver, config_dict)
is_button_clicked = force_press_button(driver, By.CSS_SELECTOR,'div.ui-dialog-buttonset > button.ui-button') is_button_clicked = force_press_button(driver, By.CSS_SELECTOR,'div.ui-dialog-buttonset > button.ui-button')
if config_dict["ocr_captcha"]["enable"]: if config_dict["ocr_captcha"]["enable"]:
if not is_captcha_sent: if not is_captcha_sent:
is_captcha_sent = kham_captcha(driver, config_dict, ocr, Captcha_Browser, model_name) is_captcha_sent = kham_captcha(driver, config_dict, ocr, Captcha_Browser, model_name)
is_ticket_number_assigned = kham_performance_ticket_number(driver, config_dict) is_ticket_number_assigned = False
if "ticket.com.tw" in url:
is_ticket_number_assigned = ticket_performance_ticket_number(driver, config_dict)
else:
is_ticket_number_assigned = kham_performance_ticket_number(driver, config_dict)
if is_ticket_number_assigned: if is_ticket_number_assigned:
if is_captcha_sent: if is_captcha_sent:
el_btn = None el_btn = None
# for kham
my_css_selector = 'button[onclick="addShoppingCart();return false;"]' my_css_selector = 'button[onclick="addShoppingCart();return false;"]'
if "ticket.com.tw" in url:
my_css_selector = 'a[onclick="return chkCart();"]'
try: try:
el_btn = driver.find_element(By.CSS_SELECTOR, my_css_selector) el_btn = driver.find_element(By.CSS_SELECTOR, my_css_selector)
if not el_btn is None: if not el_btn is None:

View File

@ -22,7 +22,7 @@ import base64
import threading import threading
import subprocess import subprocess
CONST_APP_VERSION = "MaxBot (2023.09.13)" CONST_APP_VERSION = "MaxBot (2023.09.14)"
CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json" CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"

View File

@ -35,7 +35,7 @@ import ssl
ssl._create_default_https_context = ssl._create_unverified_context ssl._create_default_https_context = ssl._create_unverified_context
CONST_APP_VERSION = "MaxBot (2023.09.13)" CONST_APP_VERSION = "MaxBot (2023.09.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"

View File

@ -28,7 +28,7 @@ import asyncio
import tornado import tornado
from tornado.web import Application from tornado.web import Application
CONST_APP_VERSION = "MaxBot (2023.09.13)" CONST_APP_VERSION = "MaxBot (2023.09.14)"
CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt" CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt"