add debug messages for launch chrome fail...
parent
d1d69d10ac
commit
01e04f841b
|
@ -54,7 +54,7 @@ import webbrowser
|
|||
import argparse
|
||||
import chromedriver_autoinstaller
|
||||
|
||||
CONST_APP_VERSION = "MaxBot (2023.08.02)"
|
||||
CONST_APP_VERSION = "MaxBot (2023.08.03)"
|
||||
|
||||
CONST_MAXBOT_CONFIG_FILE = "settings.json"
|
||||
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
|
||||
|
@ -416,8 +416,8 @@ def load_chromdriver_normal(config_dict, driver_type):
|
|||
os.mkdir(webdriver_path)
|
||||
|
||||
if not os.path.exists(chromedriver_path):
|
||||
print("WebDriver not exist, try to download...")
|
||||
chromedriver_autoinstaller.install(path="webdriver", make_version_dir=False)
|
||||
print("WebDriver not exist, try to download to:", webdriver_path)
|
||||
chromedriver_autoinstaller.install(path=webdriver_path, make_version_dir=False)
|
||||
|
||||
if not os.path.exists(chromedriver_path):
|
||||
print("Please download chromedriver and extract zip to webdriver folder from this url:")
|
||||
|
@ -472,7 +472,6 @@ def load_chromdriver_normal(config_dict, driver_type):
|
|||
return driver
|
||||
|
||||
def clean_uc_exe_cache():
|
||||
is_cache_exist = False
|
||||
exe_name = "chromedriver%s"
|
||||
|
||||
platform = sys.platform
|
||||
|
@ -496,16 +495,16 @@ def clean_uc_exe_cache():
|
|||
d = "~/.undetected_chromedriver"
|
||||
data_path = os.path.abspath(os.path.expanduser(d))
|
||||
|
||||
is_cache_exist = False
|
||||
p = pathlib.Path(data_path)
|
||||
files = list(p.rglob("*chromedriver*?"))
|
||||
for file in files:
|
||||
is_cache_exist = True
|
||||
if os.path.exists(str(file)):
|
||||
is_cache_exist = True
|
||||
try:
|
||||
os.unlink(str(file))
|
||||
except PermissionError:
|
||||
pass
|
||||
except FileNotFoundError:
|
||||
except Exception as exc2:
|
||||
print(exc2)
|
||||
pass
|
||||
|
||||
return is_cache_exist
|
||||
|
@ -527,8 +526,10 @@ def load_chromdriver_uc(config_dict):
|
|||
os.mkdir(webdriver_path)
|
||||
|
||||
if not os.path.exists(chromedriver_path):
|
||||
print("WebDriver not exist, try to download...")
|
||||
chromedriver_autoinstaller.install(path="webdriver", make_version_dir=False)
|
||||
print("ChromeDriver not exist, try to download to:", webdriver_path)
|
||||
chromedriver_autoinstaller.install(path=webdriver_path, make_version_dir=False)
|
||||
else:
|
||||
print("ChromeDriver exist:", chromedriver_path)
|
||||
|
||||
options = uc.ChromeOptions()
|
||||
options.page_load_strategy = 'eager'
|
||||
|
@ -586,13 +587,13 @@ def load_chromdriver_uc(config_dict):
|
|||
|
||||
# remove exist chromedriver, download again.
|
||||
try:
|
||||
print("Deleting exist and download ChromeDriver again.")
|
||||
os.unlink(chromedriver_path)
|
||||
except PermissionError:
|
||||
pass
|
||||
except FileNotFoundError:
|
||||
except Exception as exc2:
|
||||
print(exc2)
|
||||
pass
|
||||
|
||||
chromedriver_autoinstaller.install(path="webdriver", make_version_dir=False)
|
||||
chromedriver_autoinstaller.install(path=webdriver_path, make_version_dir=False)
|
||||
try:
|
||||
driver = uc.Chrome(driver_executable_path=chromedriver_path, options=options, headless=config_dict["advanced"]["headless"])
|
||||
except Exception as exc2:
|
||||
|
|
Loading…
Reference in New Issue