2023-10-15, update fot ticketplus.

master
CHUN YU YAO 2023-10-29 22:49:02 +08:00
parent 61994da92f
commit dc5b44dc8b
4 changed files with 106 additions and 107 deletions

View File

@ -55,7 +55,7 @@ import webbrowser
import chromedriver_autoinstaller import chromedriver_autoinstaller
CONST_APP_VERSION = "MaxBot (2023.10.14)" CONST_APP_VERSION = "MaxBot (2023.10.15)"
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"
@ -114,8 +114,11 @@ def format_config_keyword_for_json(user_input):
return user_input return user_input
def remove_html_tags(text): def remove_html_tags(text):
clean = re.compile('<.*?>') ret = ""
return re.sub(clean, '', text) if not text is None:
clean = re.compile('<.*?>')
ret = re.sub(clean, '', text)
return ret
def sx(s1): def sx(s1):
key=18 key=18
@ -338,7 +341,7 @@ def is_all_alpha_or_numeric(text):
def get_favoriate_extension_path(webdriver_path): def get_favoriate_extension_path(webdriver_path):
print("webdriver_path:", webdriver_path) print("webdriver_path:", webdriver_path)
extension_list = [] extension_list = []
extension_list.append(os.path.join(webdriver_path,"Adblock_3.19.0.0.crx")) extension_list.append(os.path.join(webdriver_path,"Adblock_3.20.0.0.crx"))
return extension_list return extension_list
def get_chromedriver_path(webdriver_path): def get_chromedriver_path(webdriver_path):
@ -1750,12 +1753,12 @@ def tixcraft_date_auto_select(driver, url, config_dict, domain_name):
row_is_enabled=True row_is_enabled=True
try: try:
row_text = "" row_text = ""
row_html = ""
# check buy button. # check buy button.
if row_is_enabled: if row_is_enabled:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
if row_text is None: row_text = remove_html_tags(row_html)
row_text = ""
if len(row_text) > 0: if len(row_text) > 0:
if reset_row_text_if_match_keyword_exclude(config_dict, row_text): if reset_row_text_if_match_keyword_exclude(config_dict, row_text):
@ -1929,12 +1932,12 @@ def ticketmaster_date_auto_select(driver, url, config_dict, domain_name):
row_is_enabled=False row_is_enabled=False
row_text = "" row_text = ""
row_html = ""
# check buy button. # check buy button.
if row_is_enabled: if row_is_enabled:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
if row_text is None: row_text = remove_html_tags(row_html)
row_text = ""
row_is_enabled=False row_is_enabled=False
# must contains 'See Tickets' # must contains 'See Tickets'
@ -2039,13 +2042,14 @@ def get_matched_blocks_by_keyword_item_set(config_dict, auto_select_mode, keywor
matched_blocks = [] matched_blocks = []
for row in formated_area_list: for row in formated_area_list:
row_text = "" row_text = ""
row_html = ""
try: try:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
row_text = remove_html_tags(row_html)
except Exception as exc: except Exception as exc:
pass pass
if row_text is None:
row_text = ""
if len(row_text) > 0: if len(row_text) > 0:
if reset_row_text_if_match_keyword_exclude(config_dict, row_text): if reset_row_text_if_match_keyword_exclude(config_dict, row_text):
row_text = "" row_text = ""
@ -2170,17 +2174,15 @@ def get_tixcraft_target_area(el, config_dict, area_keyword_item):
pass pass
row_text = "" row_text = ""
row_html = ""
if row_is_enabled: if row_is_enabled:
try: try:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
row_text = remove_html_tags(row_html)
except Exception as exc: except Exception as exc:
print("get text fail")
break break
if row_text is None:
row_text = ""
if len(row_text) > 0: if len(row_text) > 0:
if reset_row_text_if_match_keyword_exclude(config_dict, row_text): if reset_row_text_if_match_keyword_exclude(config_dict, row_text):
row_text = "" row_text = ""
@ -3133,17 +3135,15 @@ def get_tixcraft_ticket_select_by_keyword(driver, config_dict, area_keyword_item
pass pass
row_text = "" row_text = ""
row_html = ""
if row_is_enabled: if row_is_enabled:
try: try:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
row_text = remove_html_tags(row_html)
except Exception as exc: except Exception as exc:
print("get text fail")
break break
if row_text is None:
row_text = ""
if len(row_text) > 0: if len(row_text) > 0:
if reset_row_text_if_match_keyword_exclude(config_dict, row_text): if reset_row_text_if_match_keyword_exclude(config_dict, row_text):
row_text = "" row_text = ""
@ -3377,7 +3377,7 @@ def kktix_confirm_order_button(driver):
# : 2: /events/xxx/registrations/new # : 2: /events/xxx/registrations/new
# : This is ONLY for case-1, because case-2 lenght >5 # : This is ONLY for case-1, because case-2 lenght >5
def kktix_events_press_next_button(driver): def kktix_events_press_next_button(driver):
is_button_clicked = force_press_button(driver, By.CSS_SELECTOR,'div.tickets a.btn-point') is_button_clicked = force_press_button(driver, By.CSS_SELECTOR,'.tickets > a.btn-point')
return is_button_clicked return is_button_clicked
# : This is for case-2 next button. # : This is for case-2 next button.
@ -3530,19 +3530,15 @@ def kktix_travel_price_list(driver, config_dict, kktix_area_keyword):
row_index += 1 row_index += 1
row_text = "" row_text = ""
row_html = ""
try: try:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
if show_debug_message: row_text = remove_html_tags(row_html)
print("get text:", row_text, ",at row:", row_index)
except Exception as exc: except Exception as exc:
row_text = ""
is_travel_interrupted = True is_travel_interrupted = True
print("get text fail.") print("get text fail.")
if row_text is None:
row_text = ""
if '已售完' in row_text: if '已售完' in row_text:
row_text = "" row_text = ""
@ -4645,6 +4641,7 @@ def get_fami_target_area(driver, config_dict, area_keyword_item):
area_html_text = "" area_html_text = ""
row_text = "" row_text = ""
row_html = ""
try: try:
my_css_selector = "td:nth-child(1)" my_css_selector = "td:nth-child(1)"
td_date = row.find_element(By.CSS_SELECTOR, my_css_selector) td_date = row.find_element(By.CSS_SELECTOR, my_css_selector)
@ -4659,14 +4656,12 @@ def get_fami_target_area(driver, config_dict, area_keyword_item):
area_html_text = format_keyword_string(td_area.text) area_html_text = format_keyword_string(td_area.text)
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
row_text = remove_html_tags(row_html)
except Exception as exc: except Exception as exc:
print("get row text fail") print("get row text fail")
break break
if row_text is None:
row_text = ""
if len(row_text) > 0: if len(row_text) > 0:
if reset_row_text_if_match_keyword_exclude(config_dict, row_text): if reset_row_text_if_match_keyword_exclude(config_dict, row_text):
row_text = "" row_text = ""
@ -4985,16 +4980,15 @@ def urbtix_date_auto_select(driver, auto_select_mode, date_keyword, auto_reload_
row_is_enabled=True row_is_enabled=True
if row_is_enabled: if row_is_enabled:
row_text = "" row_text = ""
row_html = ""
try: try:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
row_text = remove_html_tags(row_html)
except Exception as exc: except Exception as exc:
print("get text fail") print("get text fail")
break break
if row_text is None:
row_text = ""
if len(row_text) > 0: if len(row_text) > 0:
if show_debug_message: if show_debug_message:
print("row_text:", row_text) print("row_text:", row_text)
@ -5132,16 +5126,15 @@ def urbtix_area_auto_select(driver, config_dict, area_keyword_item):
row_is_enabled=True row_is_enabled=True
row_text = "" row_text = ""
row_html = ""
if row_is_enabled: if row_is_enabled:
try: try:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
row_text = remove_html_tags(row_html)
except Exception as exc: except Exception as exc:
pass pass
if row_text is None:
row_text = ""
if len(row_text) > 0: if len(row_text) > 0:
if reset_row_text_if_match_keyword_exclude(config_dict, row_text): if reset_row_text_if_match_keyword_exclude(config_dict, row_text):
row_text = "" row_text = ""
@ -5200,16 +5193,15 @@ def urbtix_area_auto_select(driver, config_dict, area_keyword_item):
row_is_enabled=True row_is_enabled=True
if row_is_enabled: if row_is_enabled:
row_text = "" row_text = ""
row_html = ""
try: try:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
row_text = remove_html_tags(row_html)
except Exception as exc: except Exception as exc:
print("get text fail") print("get text fail")
break break
if row_text is None:
row_text = ""
if len(row_text) > 0: if len(row_text) > 0:
row_text = format_keyword_string(row_text) row_text = format_keyword_string(row_text)
if show_debug_message: if show_debug_message:
@ -5566,16 +5558,15 @@ def cityline_date_auto_select(driver, auto_select_mode, date_keyword, auto_reloa
row_is_enabled=True row_is_enabled=True
if row_is_enabled: if row_is_enabled:
row_text = "" row_text = ""
row_html = ""
try: try:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
row_text = remove_html_tags(row_html)
except Exception as exc: except Exception as exc:
print("get text fail") print("get text fail")
break break
if row_text is None:
row_text = ""
if len(row_text) > 0: if len(row_text) > 0:
if show_debug_message: if show_debug_message:
print("row_text:", row_text) print("row_text:", row_text)
@ -5722,16 +5713,15 @@ def cityline_area_auto_select(driver, config_dict, area_keyword_item):
row_is_enabled=True row_is_enabled=True
if row_is_enabled: if row_is_enabled:
row_text = "" row_text = ""
row_html = ""
try: try:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
row_text = remove_html_tags(row_html)
except Exception as exc: except Exception as exc:
print("get text fail") print("get text fail")
break break
if row_text is None:
row_text = ""
if len(row_text) > 0: if len(row_text) > 0:
if reset_row_text_if_match_keyword_exclude(config_dict, row_text): if reset_row_text_if_match_keyword_exclude(config_dict, row_text):
row_text = "" row_text = ""
@ -6217,16 +6207,15 @@ def ibon_area_auto_select(driver, config_dict, area_keyword_item):
row_is_enabled=True row_is_enabled=True
row_text = "" row_text = ""
row_html = ""
if row_is_enabled: if row_is_enabled:
try: try:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
row_text = remove_html_tags(row_html)
except Exception as exc: except Exception as exc:
pass pass
if row_text is None:
row_text = ""
if '已售完' in row_text: if '已售完' in row_text:
row_is_enabled=False row_is_enabled=False
@ -6332,16 +6321,15 @@ def ibon_area_auto_select(driver, config_dict, area_keyword_item):
row_is_enabled=True row_is_enabled=True
if row_is_enabled: if row_is_enabled:
row_text = "" row_text = ""
row_html = ""
try: try:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
row_text = remove_html_tags(row_html)
except Exception as exc: except Exception as exc:
print("get text fail") print("get text fail")
break break
if row_text is None:
row_text = ""
if len(row_text) > 0: if len(row_text) > 0:
row_text = format_keyword_string(row_text) row_text = format_keyword_string(row_text)
if show_debug_message: if show_debug_message:
@ -8866,16 +8854,15 @@ def hkticketing_area_auto_select(driver, config_dict, area_keyword_item):
row_is_enabled=True row_is_enabled=True
if row_is_enabled: if row_is_enabled:
row_text = "" row_text = ""
row_html = ""
try: try:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
row_text = remove_html_tags(row_html)
except Exception as exc: except Exception as exc:
print("get text fail") print("get text fail")
break break
if row_text is None:
row_text = ""
if len(row_text) > 0: if len(row_text) > 0:
if reset_row_text_if_match_keyword_exclude(config_dict, row_text): if reset_row_text_if_match_keyword_exclude(config_dict, row_text):
row_text = "" row_text = ""
@ -9483,17 +9470,14 @@ def hkam_date_auto_select(driver, domain_name, config_dict):
row_is_enabled=False row_is_enabled=False
row_text = "" row_text = ""
row_html = ""
try: try:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
row_text = remove_html_tags(row_html)
except Exception as exc: except Exception as exc:
if show_debug_message:
print(exc)
pass pass
if row_text is None:
row_text=""
if len(row_text) > 0: if len(row_text) > 0:
if reset_row_text_if_match_keyword_exclude(config_dict, row_text): if reset_row_text_if_match_keyword_exclude(config_dict, row_text):
row_text = "" row_text = ""
@ -9691,16 +9675,14 @@ def kham_area_auto_select(driver, domain_name, config_dict, area_keyword_item):
row_is_enabled=True row_is_enabled=True
if row_is_enabled: if row_is_enabled:
row_text = "" row_text = ""
row_html = ""
try: try:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
row_text = remove_html_tags(row_html)
except Exception as exc: except Exception as exc:
print("get text fail")
break break
if row_text is None:
row_text = ""
if '售完' in row_text: if '售完' in row_text:
row_text = "" row_text = ""
@ -10558,17 +10540,13 @@ def ticketplus_date_auto_select(driver, config_dict):
''' '''
row_text = "" row_text = ""
row_html = ""
# check buy button. # check buy button.
if row_is_enabled: if row_is_enabled:
# text is failed. # .text is failed. @_@!
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
#print("row_text1:", row_text) row_text = remove_html_tags(row_html)
#print("innerHTML:", row.get_attribute('innerHTML'))
#print("innerTEXT:", remove_html_tags(row.get_attribute('innerHTML')))
if row_text is None:
row_text = ""
if len(row_text) > 0: if len(row_text) > 0:
if reset_row_text_if_match_keyword_exclude(config_dict, row_text): if reset_row_text_if_match_keyword_exclude(config_dict, row_text):
@ -10781,31 +10759,42 @@ def ticketplus_order_expansion_auto_select(driver, config_dict, area_keyword_ite
formated_area_list = [] formated_area_list = []
# filter list. # filter list.
row_index = 0 row_index = 0
soldout_count = 0
for row in area_list: for row in area_list:
row_index += 1 row_index += 1
row_is_enabled=True row_is_enabled=True
if row_is_enabled: if row_is_enabled:
row_text = "" row_text = ""
row_html = ""
try: try:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
row_text = remove_html_tags(row_html)
except Exception as exc: except Exception as exc:
pass pass
if row_text is None:
row_text = ""
# for style_2 # for style_2
if '剩餘 0' in row_text: if len(row_text) > 0:
row_text = "" if '剩餘 0' in row_text:
soldout_count += 1
row_text = ""
if '已售完' in row_text: if len(row_text) > 0:
row_text = "" if '已售完' in row_text:
soldout_count += 1
row_text = ""
# for style_1 # for style_1
if '剩餘0' in row_text: if len(row_text) > 0:
row_text = "" if '剩餘0' in row_text:
soldout_count += 1
row_text = ""
if len(row_text) > 0:
if ' soldout"' in row_html:
soldout_count += 1
row_text = ""
if len(row_text) > 0: if len(row_text) > 0:
if reset_row_text_if_match_keyword_exclude(config_dict, row_text): if reset_row_text_if_match_keyword_exclude(config_dict, row_text):
@ -10816,6 +10805,13 @@ def ticketplus_order_expansion_auto_select(driver, config_dict, area_keyword_ite
if row_is_enabled: if row_is_enabled:
formated_area_list.append(row) formated_area_list.append(row)
if soldout_count > 0:
if show_debug_message:
print("soldout_count:", soldout_count)
if area_list_count == soldout_count:
formated_area_list = None
is_need_refresh = True
else: else:
if show_debug_message: if show_debug_message:
print("area_list_count is empty.") print("area_list_count is empty.")
@ -10842,16 +10838,14 @@ def ticketplus_order_expansion_auto_select(driver, config_dict, area_keyword_ite
row_is_enabled=True row_is_enabled=True
if row_is_enabled: if row_is_enabled:
row_text = "" row_text = ""
row_html = ""
try: try:
#row_text = row.text #row_text = row.text
row_text = remove_html_tags(row.get_attribute('innerHTML')) row_html = row.get_attribute('innerHTML')
row_text = remove_html_tags(row_html)
except Exception as exc: except Exception as exc:
print("get text fail")
break break
if row_text is None:
row_text = ""
if len(row_text) > 0: if len(row_text) > 0:
row_text = format_keyword_string(row_text) row_text = format_keyword_string(row_text)
if show_debug_message: if show_debug_message:
@ -10912,16 +10906,21 @@ def ticketplus_order_expansion_auto_select(driver, config_dict, area_keyword_ite
if current_layout_style==1: if current_layout_style==1:
if not target_area is None: if not target_area is None:
try: try:
if target_area.is_enabled(): target_area.click()
target_area.click()
except Exception as exc: except Exception as exc:
print("click target_area link fail") print("click target_area link fail")
print(exc) print(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();", target_area) js = """let titleBar = document.getElementById("titleBar");
if(titleBar!=null) {titleBar.innerHTML="";}
arguments[0].scrollIntoView();
arguments[0].firstChild.click();
"""
driver.execute_script(js, target_area)
except Exception as exc: except Exception as exc:
#print(exc)
pass pass
is_price_assign_by_bot = False is_price_assign_by_bot = False

View File

@ -22,7 +22,7 @@ import base64
import threading import threading
import subprocess import subprocess
CONST_APP_VERSION = "MaxBot (2023.10.13)" CONST_APP_VERSION = "MaxBot (2023.10.15)"
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

@ -34,7 +34,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.10.14)" CONST_APP_VERSION = "MaxBot (2023.10.15)"
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.10.13)" CONST_APP_VERSION = "MaxBot (2023.10.15)"
CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt" CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt"