fix bugs for tixcraft.

master
CHUN YU YAO 2023-03-08 22:41:47 +08:00
parent 318304cca1
commit da3678960e
3 changed files with 30 additions and 21 deletions

View File

@ -53,10 +53,12 @@ import argparse
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.03.07).02" CONST_APP_VERSION = u"MaxBot (2023.03.08)"
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'
URL_CHROME_DRIVER = 'https://chromedriver.chromium.org/'
CONST_CHROME_VERSION_NOT_MATCH_EN="Please download the WebDriver version to match your browser version." CONST_CHROME_VERSION_NOT_MATCH_EN="Please download the WebDriver version to match your browser version."
CONST_CHROME_VERSION_NOT_MATCH_TW="請下載與您瀏覽器相同版本的WebDriver版本或更新您的瀏覽器版本。" CONST_CHROME_VERSION_NOT_MATCH_TW="請下載與您瀏覽器相同版本的WebDriver版本或更新您的瀏覽器版本。"
@ -267,10 +269,16 @@ def get_chrome_options(webdriver_path, adblock_plus_enable, browser="chrome", he
return chrome_options, caps return chrome_options, caps
def load_chromdriver_normal(webdriver_path, driver_type, adblock_plus_enable, headless): def load_chromdriver_normal(webdriver_path, driver_type, adblock_plus_enable, headless):
driver = None
chromedriver_path = get_chromedriver_path(webdriver_path) chromedriver_path = get_chromedriver_path(webdriver_path)
if not os.path.exists(chromedriver_path):
print("Please download chromedriver and extract zip to webdriver folder from this url:")
print("請下在面的網址下載與你chrome瀏覽器相同版本的chromedriver,解壓縮後放到webdriver目錄裡")
print(URL_CHROME_DRIVER)
else:
chrome_service = Service(chromedriver_path) chrome_service = Service(chromedriver_path)
chrome_options, caps = get_chrome_options(webdriver_path, adblock_plus_enable, headless=headless) chrome_options, caps = get_chrome_options(webdriver_path, adblock_plus_enable, headless=headless)
driver = None
try: try:
# method 6: Selenium Stealth # method 6: Selenium Stealth
driver = webdriver.Chrome(service=chrome_service, options=chrome_options, desired_capabilities=caps) driver = webdriver.Chrome(service=chrome_service, options=chrome_options, desired_capabilities=caps)
@ -358,7 +366,8 @@ def load_chromdriver_uc(webdriver_path, adblock_plus_enable, headless):
pass pass
if is_local_chrome_browser_lower: if is_local_chrome_browser_lower:
print("Use local user downloaded chromedriver to lunch chrome browser.") print("Unable to use undetected_chromedriver, ")
print("try to use local chromedriver to launch chrome browser.")
driver_type = "selenium" driver_type = "selenium"
driver = load_chromdriver_normal(webdriver_path, driver_type, adblock_plus_enable, headless) driver = load_chromdriver_normal(webdriver_path, driver_type, adblock_plus_enable, headless)
else: else:
@ -376,7 +385,6 @@ def load_chromdriver_uc(webdriver_path, adblock_plus_enable, headless):
if "This version of ChromeDriver only supports Chrome version" in error_message: if "This version of ChromeDriver only supports Chrome version" in error_message:
print(CONST_CHROME_VERSION_NOT_MATCH_EN) print(CONST_CHROME_VERSION_NOT_MATCH_EN)
print(CONST_CHROME_VERSION_NOT_MATCH_TW) print(CONST_CHROME_VERSION_NOT_MATCH_TW)
is_local_chrome_browser_lower = True
pass pass
if driver is None: if driver is None:
@ -1419,8 +1427,9 @@ def tixcraft_date_auto_select(driver, url, config_dict, domain_name):
matched_blocks = formated_area_list matched_blocks = formated_area_list
else: else:
# match keyword. # match keyword.
date_keyword = format_keyword_string(date_keyword)
if show_debug_message: if show_debug_message:
print("start to match keyword:", date_keyword) print("start to match formated keyword:", date_keyword)
matched_blocks = [] matched_blocks = []
row_index = 0 row_index = 0

View File

@ -20,7 +20,7 @@ import json
import webbrowser import webbrowser
import base64 import base64
CONST_APP_VERSION = u"MaxBot (2023.03.07).02" CONST_APP_VERSION = u"MaxBot (2023.03.08)"
CONST_LAUNCHER_CONFIG_FILENAME = "config_launcher.json" CONST_LAUNCHER_CONFIG_FILENAME = "config_launcher.json"

View File

@ -21,7 +21,7 @@ import webbrowser
import pyperclip import pyperclip
import base64 import base64
CONST_APP_VERSION = u"MaxBot (2023.03.07).02" CONST_APP_VERSION = u"MaxBot (2023.03.08)"
CONST_SETTINGS_CONFIG_FILENAME = "settings.json" CONST_SETTINGS_CONFIG_FILENAME = "settings.json"