2023-10-23, remove headless mode.
parent
c32708dffc
commit
ca1f53bfa6
|
@ -55,7 +55,7 @@ import webbrowser
|
|||
|
||||
import chromedriver_autoinstaller
|
||||
|
||||
CONST_APP_VERSION = "MaxBot (2023.10.22)"
|
||||
CONST_APP_VERSION = "MaxBot (2023.10.23)"
|
||||
|
||||
CONST_MAXBOT_CONFIG_FILE = "settings.json"
|
||||
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
|
||||
|
@ -162,12 +162,6 @@ def get_config_dict(args):
|
|||
with open(config_filepath) as json_data:
|
||||
config_dict = json.load(json_data)
|
||||
|
||||
# start to overwrite config settings.
|
||||
if not args.headless is None:
|
||||
headless_flag = t_or_f(args.headless)
|
||||
if headless_flag:
|
||||
config_dict["advanced"]["headless"] = True
|
||||
|
||||
if not args.homepage is None:
|
||||
if len(args.homepage) > 0:
|
||||
config_dict["homepage"] = args.homepage
|
||||
|
@ -194,20 +188,6 @@ def get_config_dict(args):
|
|||
if len(args.proxy_server) > 2:
|
||||
config_dict["advanced"]["proxy_server_port"] = args.proxy_server
|
||||
|
||||
|
||||
|
||||
# special case for headless to enable away from keyboard mode.
|
||||
is_headless_enable = False
|
||||
if config_dict["advanced"]["headless"]:
|
||||
# for tixcraft headless.
|
||||
if len(config_dict["advanced"]["tixcraft_sid"]) > 1:
|
||||
is_headless_enable = True
|
||||
else:
|
||||
print("If you are runnig headless mode on tixcraft, you need input your cookie SID.")
|
||||
|
||||
if is_headless_enable:
|
||||
config_dict["ocr_captcha"]["enable"] = True
|
||||
config_dict["ocr_captcha"]["force_submit"] = True
|
||||
return config_dict
|
||||
|
||||
def write_question_to_file(question_text):
|
||||
|
@ -374,7 +354,6 @@ def get_brave_bin_path():
|
|||
def get_chrome_options(webdriver_path, config_dict):
|
||||
adblock_plus_enable = config_dict["advanced"]["adblock_plus_enable"]
|
||||
browser=config_dict["browser"]
|
||||
headless=config_dict["advanced"]["headless"]
|
||||
|
||||
chrome_options = webdriver.ChromeOptions()
|
||||
if browser=="edge":
|
||||
|
@ -389,9 +368,6 @@ def get_chrome_options(webdriver_path, config_dict):
|
|||
for ext in extension_list:
|
||||
if os.path.exists(ext):
|
||||
chrome_options.add_extension(ext)
|
||||
if headless:
|
||||
#chrome_options.add_argument('--headless')
|
||||
chrome_options.add_argument('--headless=new')
|
||||
chrome_options.add_argument('--disable-features=TranslateUI')
|
||||
chrome_options.add_argument('--disable-translate')
|
||||
chrome_options.add_argument('--lang=zh-TW')
|
||||
|
@ -558,9 +534,6 @@ def get_uc_options(uc, config_dict, webdriver_path):
|
|||
print('load-extension:', load_extension_path[1:])
|
||||
options.add_argument('--load-extension=' + load_extension_path[1:])
|
||||
|
||||
if config_dict["advanced"]["headless"]:
|
||||
#options.add_argument('--headless')
|
||||
options.add_argument('--headless=new')
|
||||
options.add_argument('--disable-features=TranslateUI')
|
||||
options.add_argument('--disable-translate')
|
||||
options.add_argument('--lang=zh-TW')
|
||||
|
@ -615,7 +588,7 @@ def load_chromdriver_uc(config_dict):
|
|||
|
||||
try:
|
||||
options = get_uc_options(uc, config_dict, webdriver_path)
|
||||
driver = uc.Chrome(driver_executable_path=chromedriver_path, options=options, headless=config_dict["advanced"]["headless"])
|
||||
driver = uc.Chrome(driver_executable_path=chromedriver_path, options=options)
|
||||
except Exception as exc:
|
||||
print(exc)
|
||||
error_message = str(exc)
|
||||
|
@ -639,7 +612,7 @@ def load_chromdriver_uc(config_dict):
|
|||
try:
|
||||
chromedriver_autoinstaller.install(path=webdriver_path, make_version_dir=False)
|
||||
options = get_uc_options(uc, config_dict, webdriver_path)
|
||||
driver = uc.Chrome(driver_executable_path=chromedriver_path, options=options, headless=config_dict["advanced"]["headless"])
|
||||
driver = uc.Chrome(driver_executable_path=chromedriver_path, options=options)
|
||||
except Exception as exc2:
|
||||
print(exc2)
|
||||
pass
|
||||
|
@ -650,7 +623,7 @@ def load_chromdriver_uc(config_dict):
|
|||
print('WebDriver object is None..., try again..')
|
||||
try:
|
||||
options = get_uc_options(uc, config_dict, webdriver_path)
|
||||
driver = uc.Chrome(options=options, headless=config_dict["advanced"]["headless"])
|
||||
driver = uc.Chrome(options=options)
|
||||
except Exception as exc:
|
||||
print(exc)
|
||||
error_message = str(exc)
|
||||
|
@ -750,9 +723,6 @@ def get_driver_by_config(config_dict):
|
|||
try:
|
||||
from selenium.webdriver.firefox.options import Options
|
||||
options = Options()
|
||||
if config_dict["advanced"]["headless"]:
|
||||
options.add_argument('--headless')
|
||||
#options.add_argument('--headless=new')
|
||||
if platform.system().lower()=="windows":
|
||||
binary_path = "C:\\Program Files\\Mozilla Firefox\\firefox.exe"
|
||||
if not os.path.exists(binary_path):
|
||||
|
@ -1589,6 +1559,21 @@ def force_press_button_iframe(driver, f, select_by, select_query, force_submit=T
|
|||
|
||||
return is_clicked
|
||||
|
||||
def clean_tag_by_selector(driver, select_query):
|
||||
try:
|
||||
driver.set_script_timeout(1)
|
||||
js = """var selectSoldoutItems = document.querySelectorAll('%s');
|
||||
selectSoldoutItems.forEach((userItem) =>
|
||||
{
|
||||
userItem.outerHTML="";
|
||||
}
|
||||
);""" % select_query
|
||||
|
||||
driver.execute_script(js)
|
||||
ret = True
|
||||
except Exception as exc:
|
||||
pass
|
||||
|
||||
def force_press_button(driver, select_by, select_query, force_submit=True):
|
||||
ret = False
|
||||
next_step_button = None
|
||||
|
@ -7619,17 +7604,6 @@ def tixcraft_main(driver, url, config_dict, tixcraft_dict, ocr, Captcha_Browser)
|
|||
domain_name = url.split('/')[2]
|
||||
tixcraft_ticket_main(driver, config_dict, ocr, Captcha_Browser, domain_name)
|
||||
|
||||
if '/ticket/checkout' in url:
|
||||
if config_dict["advanced"]["headless"]:
|
||||
if not tixcraft_dict["is_popup_checkout"]:
|
||||
domain_name = url.split('/')[2]
|
||||
checkout_url = "https://%s/ticket/checkout" % (domain_name)
|
||||
print("搶票成功, 請前往該帳號訂單查看: %s" % (checkout_url))
|
||||
webbrowser.open_new(checkout_url)
|
||||
tixcraft_dict["is_popup_checkout"] = True
|
||||
else:
|
||||
tixcraft_dict["is_popup_checkout"] = False
|
||||
|
||||
return tixcraft_dict
|
||||
|
||||
def kktix_main(driver, url, config_dict, kktix_dict):
|
||||
|
@ -7673,23 +7647,6 @@ def kktix_main(driver, url, config_dict, kktix_dict):
|
|||
kktix_dict["captcha_sound_played"] = False
|
||||
kktix_dict["kktix_register_status_last"] = None
|
||||
|
||||
if '/events/' in url and '/registrations/' in url and "-" in url:
|
||||
if config_dict["advanced"]["headless"]:
|
||||
if not kktix_dict["is_popup_checkout"]:
|
||||
is_event_page = False
|
||||
if len(url.split('/'))==8:
|
||||
is_event_page = True
|
||||
if is_event_page:
|
||||
confirm_clicked = kktix_confirm_order_button(driver)
|
||||
if confirm_clicked:
|
||||
domain_name = url.split('/')[2]
|
||||
checkout_url = "https://%s/account/orders" % (domain_name)
|
||||
print("搶票成功, 請前往該帳號訂單查看: %s" % (checkout_url))
|
||||
webbrowser.open_new(checkout_url)
|
||||
tixcraft_dict["is_popup_checkout"] = True
|
||||
else:
|
||||
kktix_dict["is_popup_checkout"] = False
|
||||
|
||||
return kktix_dict
|
||||
|
||||
def fami_login(driver, account, password):
|
||||
|
@ -8638,6 +8595,11 @@ def ibon_main(driver, url, config_dict, ibon_dict, ocr, Captcha_Browser):
|
|||
|
||||
if is_event_page:
|
||||
if config_dict["area_auto_select"]["enable"]:
|
||||
select_query = "tr.disbled"
|
||||
clean_tag_by_selector(driver,select_query)
|
||||
select_query = "tr.sold-out"
|
||||
clean_tag_by_selector(driver,select_query)
|
||||
|
||||
is_do_ibon_performance_with_ticket_number = False
|
||||
|
||||
if 'PRODUCT_ID=' in url.upper():
|
||||
|
@ -9937,17 +9899,21 @@ def hkam_date_auto_select(driver, domain_name, config_dict):
|
|||
except Exception as exc:
|
||||
pass
|
||||
|
||||
'''
|
||||
# PS: auto reload in kham is not used, due to soldout still have clickable button to enter.
|
||||
'''
|
||||
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.4)
|
||||
time.sleep(0.3)
|
||||
except Exception as exc:
|
||||
pass
|
||||
'''
|
||||
|
||||
if config_dict["advanced"]["auto_reload_random_delay"]:
|
||||
time.sleep(random.randint(0,CONST_AUTO_RELOAD_RANDOM_DELAY_MAX_SECOND))
|
||||
'''
|
||||
|
||||
return ret
|
||||
|
||||
|
@ -10019,9 +9985,8 @@ def kham_area_auto_select(driver, domain_name, config_dict, area_keyword_item):
|
|||
row_index += 1
|
||||
formated_area_list.append(row)
|
||||
else:
|
||||
if show_debug_message:
|
||||
print("area_list_count is empty.")
|
||||
pass
|
||||
print("area list is empty, do refresh!")
|
||||
is_need_refresh = True
|
||||
else:
|
||||
if show_debug_message:
|
||||
print("area_list_count is None.")
|
||||
|
@ -10749,6 +10714,11 @@ def kham_main(driver, url, config_dict, ocr, Captcha_Browser):
|
|||
is_switch_to_auto_seat = ticket_switch_to_auto_seat(driver)
|
||||
else:
|
||||
is_switch_to_auto_seat = kham_switch_to_auto_seat(driver)
|
||||
|
||||
if "kham.com.tw" in url:
|
||||
select_query = "tr.Soldout"
|
||||
clean_tag_by_selector(driver,select_query)
|
||||
|
||||
is_price_assign_by_bot, is_captcha_sent = kham_performance(driver, config_dict, ocr, Captcha_Browser, domain_name, model_name)
|
||||
|
||||
# this is a special case, not performance_price_area_id, directly input ticket_nubmer in #amount.
|
||||
|
@ -12057,14 +12027,12 @@ def main(args):
|
|||
tixcraft_dict = {}
|
||||
tixcraft_dict["fail_list"]=[]
|
||||
tixcraft_dict["fail_promo_list"]=[]
|
||||
tixcraft_dict["is_popup_checkout"] = False
|
||||
|
||||
# for kktix
|
||||
kktix_dict = {}
|
||||
kktix_dict["fail_list"]=[]
|
||||
kktix_dict["captcha_sound_played"] = False
|
||||
kktix_dict["kktix_register_status_last"] = None
|
||||
kktix_dict["is_popup_checkout"] = False
|
||||
|
||||
fami_dict = {}
|
||||
fami_dict["last_activity"]=""
|
||||
|
@ -12218,11 +12186,6 @@ def cli():
|
|||
help="overwrite ibonqware field",
|
||||
type=str)
|
||||
|
||||
parser.add_argument("--headless",
|
||||
help="headless mode",
|
||||
default='False',
|
||||
type=str)
|
||||
|
||||
parser.add_argument("--browser",
|
||||
help="overwrite browser setting",
|
||||
default='',
|
||||
|
|
|
@ -22,7 +22,7 @@ import sys
|
|||
import threading
|
||||
import webbrowser
|
||||
|
||||
CONST_APP_VERSION = "MaxBot (2023.10.16)"
|
||||
CONST_APP_VERSION = "MaxBot (2023.10.23)"
|
||||
|
||||
CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json"
|
||||
CONST_MAXBOT_CONFIG_FILE = "settings.json"
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "auto_check_agree": true, "ocr_captcha": {"enable": true, "beta": true, "force_submit": true, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "from top to bottom"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "area_auto_select": {"enable": true, "mode": "from top to bottom", "area_keyword": ""}, "keyword_exclude": "\"\u8f2a\u6905\",\"\u8eab\u969c\",\"\u8eab\u5fc3 \u969c\u7919\",\"Restricted View\"", "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "tixcraft_sid": "", "ibonqware": "", "facebook_account": "", "kktix_account": "", "fami_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "ticket_account": "", "ticketplus_account": "", "facebook_password": "", "kktix_password": "", "fami_password": "", "urbtix_password": "", "cityline_password": "", "hkticketing_password": "", "kham_password": "", "ticket_password": "", "ticketplus_password": "", "adblock_plus_enable": false, "disable_adjacent_seat": false, "headless": false, "verbose": false, "auto_guess_options": true, "user_guess_string": "", "online_dictionary_url": "", "auto_reload_page_interval": 1.0, "auto_reload_random_delay": false, "proxy_server_port": ""}}
|
||||
{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "auto_check_agree": true, "ocr_captcha": {"enable": true, "beta": true, "force_submit": true, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "from top to bottom"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "area_auto_select": {"enable": true, "mode": "from top to bottom", "area_keyword": ""}, "keyword_exclude": "\"\u8f2a\u6905\",\"\u8eab\u969c\",\"\u8eab\u5fc3 \u969c\u7919\",\"Restricted View\"", "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "tixcraft_sid": "", "ibonqware": "", "facebook_account": "", "kktix_account": "", "fami_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "ticket_account": "", "ticketplus_account": "", "facebook_password": "", "kktix_password": "", "fami_password": "", "urbtix_password": "", "cityline_password": "", "hkticketing_password": "", "kham_password": "", "ticket_password": "", "ticketplus_password": "", "adblock_plus_enable": false, "disable_adjacent_seat": false, "verbose": false, "auto_guess_options": true, "user_guess_string": "", "online_dictionary_url": "", "auto_reload_page_interval": 1.0, "auto_reload_random_delay": false, "proxy_server_port": ""}}
|
27
settings.py
27
settings.py
|
@ -34,7 +34,7 @@ import ssl
|
|||
|
||||
ssl._create_default_https_context = ssl._create_unverified_context
|
||||
|
||||
CONST_APP_VERSION = "MaxBot (2023.10.22)"
|
||||
CONST_APP_VERSION = "MaxBot (2023.10.23)"
|
||||
|
||||
CONST_MAXBOT_CONFIG_FILE = "settings.json"
|
||||
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
|
||||
|
@ -152,7 +152,6 @@ def load_translate():
|
|||
en_us["ocr_captcha_image_source"] = 'OCR image source'
|
||||
en_us["ocr_captcha_not_support_arm"] = 'ddddocr only supports Intel CPU'
|
||||
en_us["webdriver_type"] = 'WebDriver type'
|
||||
en_us["headless"] = 'Headless mode'
|
||||
# Make the operation more talkative
|
||||
en_us["verbose"] = 'Verbose mode'
|
||||
en_us["running_status"] = 'Running Status'
|
||||
|
@ -255,7 +254,6 @@ def load_translate():
|
|||
zh_tw["ocr_captcha_image_source"] = 'OCR圖片取得方式'
|
||||
zh_tw["ocr_captcha_not_support_arm"] = 'ocr 只支援 Intel CPU'
|
||||
zh_tw["webdriver_type"] = 'WebDriver類別'
|
||||
zh_tw["headless"] = '無圖形界面模式'
|
||||
zh_tw["verbose"] = '輸出詳細除錯訊息'
|
||||
zh_tw["running_status"] = '執行狀態'
|
||||
zh_tw["running_url"] = '執行網址'
|
||||
|
@ -357,7 +355,6 @@ def load_translate():
|
|||
zh_cn["ocr_captcha_image_source"] = 'OCR图像源'
|
||||
zh_cn["ocr_captcha_not_support_arm"] = 'ddddocr 仅支持 Intel CPU'
|
||||
zh_cn["webdriver_type"] = 'WebDriver类别'
|
||||
zh_cn["headless"] = '无图形界面模式'
|
||||
zh_cn["verbose"] = '输出详细除错讯息'
|
||||
zh_cn["running_status"] = '执行状态'
|
||||
zh_cn["running_url"] = '执行网址'
|
||||
|
@ -460,7 +457,6 @@ def load_translate():
|
|||
ja_jp["ocr_captcha_image_source"] = 'OCR 画像ソース'
|
||||
ja_jp["ocr_captcha_not_support_arm"] = 'Intel CPU のみをサポートします'
|
||||
ja_jp["webdriver_type"] = 'WebDriverタイプ'
|
||||
ja_jp["headless"] = 'ヘッドレスモード'
|
||||
ja_jp["verbose"] = '詳細モード'
|
||||
ja_jp["running_status"] = 'スターテス'
|
||||
ja_jp["running_url"] = '現在の URL'
|
||||
|
@ -665,7 +661,6 @@ def get_default_config():
|
|||
|
||||
config_dict["advanced"]["adblock_plus_enable"] = False
|
||||
config_dict["advanced"]["disable_adjacent_seat"] = False
|
||||
config_dict["advanced"]["headless"] = False
|
||||
config_dict["advanced"]["verbose"] = False
|
||||
config_dict["advanced"]["auto_guess_options"] = True
|
||||
config_dict["advanced"]["user_guess_string"] = ""
|
||||
|
@ -797,7 +792,6 @@ def btn_save_act(language_code, slience_mode=False):
|
|||
global chk_state_ocr_captcha_ddddocr_beta
|
||||
global chk_state_ocr_captcha_force_submit
|
||||
global chk_state_adjacent_seat
|
||||
global chk_state_headless
|
||||
global chk_state_verbose
|
||||
global chk_state_auto_guess_options
|
||||
global combo_ocr_captcha_image_source
|
||||
|
@ -964,7 +958,6 @@ def btn_save_act(language_code, slience_mode=False):
|
|||
config_dict["ocr_captcha"]["force_submit"] = False
|
||||
|
||||
config_dict["webdriver_type"] = combo_webdriver_type.get().strip()
|
||||
config_dict["advanced"]["headless"] = bool(chk_state_headless.get())
|
||||
config_dict["advanced"]["verbose"] = bool(chk_state_verbose.get())
|
||||
|
||||
config_dict["advanced"]["auto_guess_options"] = bool(chk_state_auto_guess_options.get())
|
||||
|
@ -1228,7 +1221,6 @@ def applyNewLanguage():
|
|||
global lbl_ocr_captcha_image_source
|
||||
global lbl_ocr_captcha_not_support_arm
|
||||
global lbl_webdriver_type
|
||||
global lbl_headless
|
||||
global lbl_verbose
|
||||
global lbl_auto_guess_options
|
||||
|
||||
|
@ -1250,7 +1242,6 @@ def applyNewLanguage():
|
|||
global chk_ocr_captcha_ddddocr_beta
|
||||
global chk_ocr_captcha_force_submit
|
||||
global chk_adjacent_seat
|
||||
global chk_headless
|
||||
global chk_verbose
|
||||
global lbl_online_dictionary_url
|
||||
global lbl_online_dictionary_preview
|
||||
|
@ -1303,7 +1294,6 @@ def applyNewLanguage():
|
|||
lbl_proxy_server_port.config(text=translate[language_code]["proxy_server_port"])
|
||||
lbl_auto_reload_random_delay.config(text=translate[language_code]["auto_reload_random_delay"])
|
||||
|
||||
lbl_headless.config(text=translate[language_code]["headless"])
|
||||
lbl_verbose.config(text=translate[language_code]["verbose"])
|
||||
|
||||
lbl_online_dictionary_url.config(text=translate[language_code]["online_dictionary_url"])
|
||||
|
@ -1326,7 +1316,6 @@ def applyNewLanguage():
|
|||
chk_ocr_captcha_ddddocr_beta.config(text=translate[language_code]["enable"])
|
||||
chk_ocr_captcha_force_submit.config(text=translate[language_code]["enable"])
|
||||
chk_adjacent_seat.config(text=translate[language_code]["enable"])
|
||||
chk_headless.config(text=translate[language_code]["enable"])
|
||||
chk_verbose.config(text=translate[language_code]["enable"])
|
||||
chk_auto_guess_options.config(text=translate[language_code]["enable"])
|
||||
chk_auto_reload_random_delay.config(text=translate[language_code]["enable"])
|
||||
|
@ -2004,20 +1993,6 @@ def AdvancedTab(root, config_dict, language_code, UI_PADDING_X):
|
|||
|
||||
group_row_count+=1
|
||||
|
||||
global lbl_headless
|
||||
lbl_headless = Label(frame_group_header, text=translate[language_code]['headless'])
|
||||
lbl_headless.grid(column=0, row=group_row_count, sticky = E)
|
||||
|
||||
global chk_state_headless
|
||||
chk_state_headless = BooleanVar()
|
||||
chk_state_headless.set(config_dict['advanced']["headless"])
|
||||
|
||||
global chk_headless
|
||||
chk_headless = Checkbutton(frame_group_header, text=translate[language_code]['enable'], variable=chk_state_headless)
|
||||
chk_headless.grid(column=1, row=group_row_count, sticky = W)
|
||||
|
||||
group_row_count+=1
|
||||
|
||||
global lbl_verbose
|
||||
lbl_verbose = Label(frame_group_header, text=translate[language_code]['verbose'])
|
||||
lbl_verbose.grid(column=0, row=group_row_count, sticky = E)
|
||||
|
|
|
@ -27,7 +27,7 @@ import pyperclip
|
|||
import tornado
|
||||
from tornado.web import Application
|
||||
|
||||
CONST_APP_VERSION = "MaxBot (2023.10.16)"
|
||||
CONST_APP_VERSION = "MaxBot (2023.10.23)"
|
||||
|
||||
CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt"
|
||||
|
||||
|
|
Loading…
Reference in New Issue