From f7e434c6e34d64522daa411745bdbb91428b56b4 Mon Sep 17 00:00:00 2001 From: ngosang Date: Tue, 18 Jul 2023 20:52:42 +0200 Subject: [PATCH] Simplify 'Verify you are human' resolver. Related #811 --- src/utils.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/utils.py b/src/utils.py index 47d59c5..9ccad5d 100644 --- a/src/utils.py +++ b/src/utils.py @@ -62,7 +62,6 @@ def get_webdriver(proxy: dict = None) -> WebDriver: # workaround for updated 'verify your are human' check # https://github.com/FlareSolverr/FlareSolverr/issues/811 options.add_argument('--auto-open-devtools-for-tabs') - options.add_argument('--headless=true') if proxy and 'url' in proxy: proxy_url = proxy['url'] @@ -96,19 +95,13 @@ def get_webdriver(proxy: dict = None) -> WebDriver: # if we don't set driver_executable_path it downloads, patches, and deletes the driver each time driver = uc.Chrome(options=options, browser_executable_path=browser_executable_path, driver_executable_path=driver_exe_path, version_main=version_main, - windows_headless=windows_headless) + windows_headless=windows_headless, headless=windows_headless) # save the patched driver to avoid re-downloads if driver_exe_path is None: PATCHED_DRIVER_PATH = os.path.join(driver.patcher.data_path, driver.patcher.exe_name) - shutil.copy(driver.patcher.executable_path, PATCHED_DRIVER_PATH) - - # workaround for updated 'verify your are human' check - # https://github.com/FlareSolverr/FlareSolverr/issues/811 - driver.execute_script('''window.open("","_blank");''') - driver.switch_to.window(window_name=driver.window_handles[0]) - driver.close() - driver.switch_to.window(window_name=driver.window_handles[0]) + if PATCHED_DRIVER_PATH != driver.patcher.executable_path: + shutil.copy(driver.patcher.executable_path, PATCHED_DRIVER_PATH) # selenium vanilla # options = webdriver.ChromeOptions()