2023-02-11.002, add webdriver type to switch.

master
CHUN YU YAO 2023-02-12 11:02:16 +08:00
parent a28263976e
commit 913d05d1f9
3 changed files with 53 additions and 24 deletions

View File

@ -51,7 +51,7 @@ except Exception as exc:
import ssl import ssl
ssl._create_default_https_context = ssl._create_unverified_context ssl._create_default_https_context = ssl._create_unverified_context
CONST_APP_VERSION = u"MaxBot (2023.02.10)" CONST_APP_VERSION = u"MaxBot (2023.02.11).002"
CONST_HOMEPAGE_DEFAULT = "https://tixcraft.com" CONST_HOMEPAGE_DEFAULT = "https://tixcraft.com"
URL_GOOGLE_OAUTH = 'https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&prompt=consent&response_type=code&client_id=407408718192.apps.googleusercontent.com&scope=email&access_type=offline&flowName=GeneralOAuthFlow' URL_GOOGLE_OAUTH = 'https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&prompt=consent&response_type=code&client_id=407408718192.apps.googleusercontent.com&scope=email&access_type=offline&flowName=GeneralOAuthFlow'
@ -72,6 +72,13 @@ CONST_SELECT_OPTIONS_ARRAY = [CONST_FROM_TOP_TO_BOTTOM, CONST_FROM_BOTTOM_TO_TOP
CONT_STRING_1_SEATS_REMAINING = [u'@1 seat(s) remaining',u'剩餘 1@',u'@1 席残り'] CONT_STRING_1_SEATS_REMAINING = [u'@1 seat(s) remaining',u'剩餘 1@',u'@1 席残り']
CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_BROWSER = "NonBrowser"
CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS = "canvas"
CONST_WEBDRIVER_TYPE_SELENIUM = "selenium"
#CONST_WEBDRIVER_TYPE_STEALTH = "stealth"
CONST_WEBDRIVER_TYPE_UC = "undetected_chromedriver"
def sx(s1): def sx(s1):
key=18 key=18
return ''.join(chr(ord(a) ^ key) for a in s1) return ''.join(chr(ord(a) ^ key) for a in s1)
@ -307,7 +314,7 @@ def close_browser_tabs(driver):
except Exception as excSwithFail: except Exception as excSwithFail:
pass pass
def get_driver_by_config(config_dict, driver_type): def get_driver_by_config(config_dict):
global driver global driver
homepage = None homepage = None
@ -386,6 +393,8 @@ def get_driver_by_config(config_dict, driver_type):
pass_date_is_sold_out_enable = config_dict["tixcraft"]["pass_date_is_sold_out"] pass_date_is_sold_out_enable = config_dict["tixcraft"]["pass_date_is_sold_out"]
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"]
driver_type = config_dict["webdriver_type"]
# output config: # output config:
print("maxbot app version", CONST_APP_VERSION) print("maxbot app version", CONST_APP_VERSION)
print("python version", platform.python_version()) print("python version", platform.python_version())
@ -401,6 +410,7 @@ def get_driver_by_config(config_dict, driver_type):
print(config_dict["tixcraft"]) print(config_dict["tixcraft"])
print("==[advanced]==") print("==[advanced]==")
print(config_dict["advanced"]) print(config_dict["advanced"])
print("webdriver_type", driver_type)
# entry point # entry point
if homepage is None: if homepage is None:
@ -417,7 +427,7 @@ def get_driver_by_config(config_dict, driver_type):
if browser == "chrome": if browser == "chrome":
# method 6: Selenium Stealth # method 6: Selenium Stealth
if driver_type != "undetected_chromedriver": if driver_type != CONST_WEBDRIVER_TYPE_UC:
driver = load_chromdriver_normal(webdriver_path, driver_type, adblock_plus_enable) driver = load_chromdriver_normal(webdriver_path, driver_type, adblock_plus_enable)
else: else:
# method 5: uc # method 5: uc
@ -1909,9 +1919,6 @@ def tixcraft_auto_ocr(driver, ocr, away_from_keyboard_enable, previous_answer, C
show_debug_message = False # online show_debug_message = False # online
print("start to ddddocr") print("start to ddddocr")
CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_BROWSER = "NonBrowser"
CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_CANVAS = "canvas"
is_need_redo_ocr = False is_need_redo_ocr = False
is_form_sumbited = False is_form_sumbited = False
@ -1928,7 +1935,7 @@ def tixcraft_auto_ocr(driver, ocr, away_from_keyboard_enable, previous_answer, C
if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_BROWSER: if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_BROWSER:
if not Captcha_Browser is None: if not Captcha_Browser is None:
img_base64 = base64.b64decode(Captcha_Browser.Request_Captcha()) img_base64 = base64.b64decode(Captcha_Browser.Request_Captcha())
if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_CANVAS: if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS:
image_id = 'yw0' image_id = 'yw0'
if 'indievox.com' in domain_name: if 'indievox.com' in domain_name:
image_id = 'TicketForm_verifyCode-image' image_id = 'TicketForm_verifyCode-image'
@ -1984,7 +1991,7 @@ def tixcraft_auto_ocr(driver, ocr, away_from_keyboard_enable, previous_answer, C
# selenium solution. # selenium solution.
tixcraft_reload_captcha(driver, domain_name) tixcraft_reload_captcha(driver, domain_name)
if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_CANVAS: if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS:
time.sleep(0.1) time.sleep(0.1)
else: else:
# Non_Browser solution. # Non_Browser solution.
@ -7198,7 +7205,7 @@ def kham_auto_ocr(driver, ocr, away_from_keyboard_enable, previous_answer, Captc
print("start to ddddocr") print("start to ddddocr")
CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_BROWSER = "NonBrowser" CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_BROWSER = "NonBrowser"
CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_CANVAS = "canvas" CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS = "canvas"
is_need_redo_ocr = False is_need_redo_ocr = False
is_form_sumbited = False is_form_sumbited = False
@ -7216,7 +7223,7 @@ def kham_auto_ocr(driver, ocr, away_from_keyboard_enable, previous_answer, Captc
if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_BROWSER: if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_BROWSER:
if not Captcha_Browser is None: if not Captcha_Browser is None:
img_base64 = base64.b64decode(Captcha_Browser.Request_Captcha()) img_base64 = base64.b64decode(Captcha_Browser.Request_Captcha())
if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_CANVAS: if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS:
image_id = 'chk_pic' image_id = 'chk_pic'
try: try:
form_verifyCode_base64 = driver.execute_async_script(""" form_verifyCode_base64 = driver.execute_async_script("""
@ -7265,7 +7272,7 @@ def kham_auto_ocr(driver, ocr, away_from_keyboard_enable, previous_answer, Captc
jquery_string = '$("#chk_pic").attr("src", "/pic.aspx?TYPE=%s&ts=" + new Date().getTime());' % (model_name) jquery_string = '$("#chk_pic").attr("src", "/pic.aspx?TYPE=%s&ts=" + new Date().getTime());' % (model_name)
driver.execute_script(jquery_string) driver.execute_script(jquery_string)
if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_CANVAS: if ocr_captcha_image_source == CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS:
time.sleep(0.3) time.sleep(0.3)
else: else:
# Non_Browser solution. # Non_Browser solution.
@ -7421,13 +7428,9 @@ def kham_main(driver, url, config_dict, ocr, Captcha_Browser):
def main(): def main():
config_dict = get_config_dict() config_dict = get_config_dict()
driver_type = 'selenium'
#driver_type = 'stealth'
#driver_type = 'undetected_chromedriver'
driver = None driver = None
if not config_dict is None: if not config_dict is None:
driver = get_driver_by_config(config_dict, driver_type) driver = get_driver_by_config(config_dict)
else: else:
print("Load config error!") print("Load config error!")

View File

@ -1 +1 @@
{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "pass_1_seat_remaining": true, "auto_check_agree": true, "ocr_captcha": {"enable": true, "force_submit": false, "image_source": "canvas"}, "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "area_mode": "from top to bottom", "area_keyword_1": "", "area_keyword_1_and": "", "area_keyword_2": "", "area_keyword_2_and": "", "area_keyword_2_enable": true, "auto_guess_options": true, "user_guess_string": ""}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "from top to bottom"}, "area_auto_select": {"enable": true, "area_keyword_1": "", "area_keyword_2": "", "area_keyword_3": "", "area_keyword_4": "", "area_keyword_2_enable": true, "area_keyword_3_enable": true, "area_keyword_4_enable": true, "mode": "from top to bottom"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true, "presale_code": ""}, "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "facebook_account": "", "kktix_account": "", "cityline_account": "", "urbtix_account": "", "kham_account": "", "facebook_password": "", "kktix_password": "", "cityline_password": "", "urbtix_password": "", "kham_password": "", "adblock_plus_enable": false, "open_google_oauth_url": false}, "debug": false} {"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "pass_1_seat_remaining": true, "auto_check_agree": true, "ocr_captcha": {"enable": true, "force_submit": false, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "area_mode": "from top to bottom", "area_keyword_1": "", "area_keyword_1_and": "", "area_keyword_2": "", "area_keyword_2_and": "", "area_keyword_2_enable": true, "auto_guess_options": true, "user_guess_string": ""}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "from top to bottom"}, "area_auto_select": {"enable": true, "area_keyword_1": "", "area_keyword_2": "", "area_keyword_3": "", "area_keyword_4": "", "area_keyword_2_enable": true, "area_keyword_3_enable": true, "area_keyword_4_enable": true, "mode": "from top to bottom"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true, "presale_code": ""}, "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "facebook_account": "", "kktix_account": "", "cityline_account": "", "urbtix_account": "", "kham_account": "", "facebook_password": "", "kktix_password": "", "cityline_password": "", "urbtix_password": "", "kham_password": "", "adblock_plus_enable": false, "open_google_oauth_url": false}, "debug": false}

View File

@ -20,7 +20,7 @@ import webbrowser
import pyperclip import pyperclip
import base64 import base64
CONST_APP_VERSION = u"MaxBot (2023.02.10)" CONST_APP_VERSION = u"MaxBot (2023.02.11).002"
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"
@ -38,6 +38,13 @@ tixcraft.com##.page-info.row.line-btm.mg-0'''
CONST_CAPTCHA_SOUND_FILENAME_DEFAULT = "ding-dong.wav" CONST_CAPTCHA_SOUND_FILENAME_DEFAULT = "ding-dong.wav"
CONST_HOMEPAGE_DEFAULT = "https://tixcraft.com" CONST_HOMEPAGE_DEFAULT = "https://tixcraft.com"
CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_BROWSER = "NonBrowser"
CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS = "canvas"
CONST_WEBDRIVER_TYPE_SELENIUM = "selenium"
#CONST_WEBDRIVER_TYPE_STEALTH = "stealth"
CONST_WEBDRIVER_TYPE_UC = "undetected_chromedriver"
translate={} translate={}
URL_DONATE = 'https://max-everyday.com/about/#donate' URL_DONATE = 'https://max-everyday.com/about/#donate'
@ -83,6 +90,7 @@ def load_translate():
en_us["ocr_captcha"] = 'OCR captcha' en_us["ocr_captcha"] = 'OCR captcha'
en_us["ocr_captcha_force_submit"] = 'Away from keyboard' en_us["ocr_captcha_force_submit"] = 'Away from keyboard'
en_us["ocr_captcha_image_source"] = 'OCR image source' en_us["ocr_captcha_image_source"] = 'OCR image source'
en_us["webdriver_type"] = 'WebDriver type'
en_us["preference"] = 'Preference' en_us["preference"] = 'Preference'
en_us["advanced"] = 'Advanced' en_us["advanced"] = 'Advanced'
@ -154,6 +162,7 @@ def load_translate():
zh_tw["ocr_captcha"] = '猜測驗證碼' zh_tw["ocr_captcha"] = '猜測驗證碼'
zh_tw["ocr_captcha_force_submit"] = '掛機模式' zh_tw["ocr_captcha_force_submit"] = '掛機模式'
zh_tw["ocr_captcha_image_source"] = 'OCR圖片取得方式' zh_tw["ocr_captcha_image_source"] = 'OCR圖片取得方式'
zh_tw["webdriver_type"] = 'WebDriver類別'
zh_tw["preference"] = '偏好設定' zh_tw["preference"] = '偏好設定'
zh_tw["advanced"] = '進階設定' zh_tw["advanced"] = '進階設定'
@ -231,6 +240,7 @@ def load_translate():
zh_cn["ocr_captcha"] = '猜测验证码' zh_cn["ocr_captcha"] = '猜测验证码'
zh_cn["ocr_captcha_force_submit"] = '挂机模式' zh_cn["ocr_captcha_force_submit"] = '挂机模式'
zh_cn["ocr_captcha_image_source"] = 'OCR图像源' zh_cn["ocr_captcha_image_source"] = 'OCR图像源'
zh_cn["webdriver_type"] = 'WebDriver类别'
zh_cn["preference"] = '偏好设定' zh_cn["preference"] = '偏好设定'
zh_cn["advanced"] = '進階設定' zh_cn["advanced"] = '進階設定'
@ -303,6 +313,7 @@ def load_translate():
ja_jp["ocr_captcha"] = 'キャプチャを推測する' ja_jp["ocr_captcha"] = 'キャプチャを推測する'
ja_jp["ocr_captcha_force_submit"] = 'キーボードから離れて' ja_jp["ocr_captcha_force_submit"] = 'キーボードから離れて'
ja_jp["ocr_captcha_image_source"] = 'OCR 画像ソース' ja_jp["ocr_captcha_image_source"] = 'OCR 画像ソース'
ja_jp["webdriver_type"] = 'WebDriverタイプ'
ja_jp["preference"] = '設定' ja_jp["preference"] = '設定'
ja_jp["advanced"] = '高度な設定' ja_jp["advanced"] = '高度な設定'
@ -386,7 +397,8 @@ def get_default_config():
config_dict["ocr_captcha"] = {} config_dict["ocr_captcha"] = {}
config_dict["ocr_captcha"]["enable"] = True config_dict["ocr_captcha"]["enable"] = True
config_dict["ocr_captcha"]["force_submit"] = False config_dict["ocr_captcha"]["force_submit"] = False
config_dict["ocr_captcha"]["image_source"] = "canvas" config_dict["ocr_captcha"]["image_source"] = CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS
config_dict["webdriver_type"] = CONST_WEBDRIVER_TYPE_UC
config_dict['kktix']={} config_dict['kktix']={}
config_dict["kktix"]["auto_press_next_step_button"] = True config_dict["kktix"]["auto_press_next_step_button"] = True
@ -543,6 +555,7 @@ def btn_save_act(language_code, slience_mode=False):
global chk_state_ocr_captcha_force_submit global chk_state_ocr_captcha_force_submit
global chk_state_google_oauth global chk_state_google_oauth
global combo_ocr_captcha_image_source global combo_ocr_captcha_image_source
global combo_webdriver_type
is_all_data_correct = True is_all_data_correct = True
@ -644,6 +657,7 @@ def btn_save_act(language_code, slience_mode=False):
config_dict["ocr_captcha"]["enable"] = bool(chk_state_ocr_captcha.get()) config_dict["ocr_captcha"]["enable"] = bool(chk_state_ocr_captcha.get())
config_dict["ocr_captcha"]["force_submit"] = bool(chk_state_ocr_captcha_force_submit.get()) config_dict["ocr_captcha"]["force_submit"] = bool(chk_state_ocr_captcha_force_submit.get())
config_dict["ocr_captcha"]["image_source"] = combo_ocr_captcha_image_source.get().strip() config_dict["ocr_captcha"]["image_source"] = combo_ocr_captcha_image_source.get().strip()
config_dict["webdriver_type"] = combo_webdriver_type.get().strip()
# save config. # save config.
if is_all_data_correct: if is_all_data_correct:
@ -806,6 +820,7 @@ def applyNewLanguage():
global lbl_ocr_captcha global lbl_ocr_captcha
global lbl_ocr_captcha_force_submit global lbl_ocr_captcha_force_submit
global lbl_ocr_captcha_image_source global lbl_ocr_captcha_image_source
global lbl_webdriver_type
# for checkbox # for checkbox
global chk_pass_1_seat_remaining global chk_pass_1_seat_remaining
@ -873,6 +888,7 @@ def applyNewLanguage():
lbl_ocr_captcha.config(text=translate[language_code]["ocr_captcha"]) lbl_ocr_captcha.config(text=translate[language_code]["ocr_captcha"])
lbl_ocr_captcha_force_submit.config(text=translate[language_code]["ocr_captcha_force_submit"]) lbl_ocr_captcha_force_submit.config(text=translate[language_code]["ocr_captcha_force_submit"])
lbl_ocr_captcha_image_source.config(text=translate[language_code]["ocr_captcha_image_source"]) lbl_ocr_captcha_image_source.config(text=translate[language_code]["ocr_captcha_image_source"])
lbl_webdriver_type.config(text=translate[language_code]["webdriver_type"])
lbl_google_oauth.config(text=translate[language_code]["open_google_oauth_url"]) lbl_google_oauth.config(text=translate[language_code]["open_google_oauth_url"])
chk_pass_1_seat_remaining.config(text=translate[language_code]["enable"]) chk_pass_1_seat_remaining.config(text=translate[language_code]["enable"])
@ -897,7 +913,8 @@ def applyNewLanguage():
tabControl.tab(0, text=translate[language_code]["preference"]) tabControl.tab(0, text=translate[language_code]["preference"])
tabControl.tab(1, text=translate[language_code]["advanced"]) tabControl.tab(1, text=translate[language_code]["advanced"])
tabControl.tab(2, text=translate[language_code]["about"]) tabControl.tab(2, text=translate[language_code]["autofill"])
tabControl.tab(3, text=translate[language_code]["about"])
global lbl_facebook_account global lbl_facebook_account
global lbl_kktix_account global lbl_kktix_account
@ -1763,21 +1780,30 @@ def AdvancedTab(root, config_dict, language_code, UI_PADDING_X):
group_row_count+=1 group_row_count+=1
CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_BROWSER = "NonBrowser"
CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_CANVAS = "canvas"
global lbl_ocr_captcha_image_source global lbl_ocr_captcha_image_source
lbl_ocr_captcha_image_source = Label(frame_group_header, text=translate[language_code]['ocr_captcha_image_source']) lbl_ocr_captcha_image_source = Label(frame_group_header, text=translate[language_code]['ocr_captcha_image_source'])
lbl_ocr_captcha_image_source.grid(column=0, row=group_row_count, sticky = E) lbl_ocr_captcha_image_source.grid(column=0, row=group_row_count, sticky = E)
global combo_ocr_captcha_image_source global combo_ocr_captcha_image_source
combo_ocr_captcha_image_source = ttk.Combobox(frame_group_header, state="readonly") combo_ocr_captcha_image_source = ttk.Combobox(frame_group_header, state="readonly")
combo_ocr_captcha_image_source['values']= (CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_BROWSER, CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_CANVAS) combo_ocr_captcha_image_source['values']= (CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_BROWSER, CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS)
combo_ocr_captcha_image_source.set(config_dict["ocr_captcha"]["image_source"]) combo_ocr_captcha_image_source.set(config_dict["ocr_captcha"]["image_source"])
combo_ocr_captcha_image_source.grid(column=1, row=group_row_count, sticky = W) combo_ocr_captcha_image_source.grid(column=1, row=group_row_count, sticky = W)
group_row_count+=1 group_row_count+=1
global lbl_webdriver_type
lbl_webdriver_type = Label(frame_group_header, text=translate[language_code]['webdriver_type'])
lbl_webdriver_type.grid(column=0, row=group_row_count, sticky = E)
global combo_webdriver_type
combo_webdriver_type = ttk.Combobox(frame_group_header, state="readonly")
combo_webdriver_type['values']= (CONST_WEBDRIVER_TYPE_SELENIUM, CONST_WEBDRIVER_TYPE_UC)
combo_webdriver_type.set(config_dict["webdriver_type"])
combo_webdriver_type.grid(column=1, row=group_row_count, sticky = W)
group_row_count +=1
global lbl_play_captcha_sound global lbl_play_captcha_sound
lbl_play_captcha_sound = Label(frame_group_header, text=translate[language_code]['play_captcha_sound']) lbl_play_captcha_sound = Label(frame_group_header, text=translate[language_code]['play_captcha_sound'])
lbl_play_captcha_sound.grid(column=0, row=group_row_count, sticky = E) lbl_play_captcha_sound.grid(column=0, row=group_row_count, sticky = E)