mirror of
https://github.com/JulienMalka/snowfield.git
synced 2025-07-03 07:47:20 +02:00
Flaresolverr update step 1
This commit is contained in:
parent
f4cb5ab46d
commit
8553291a5c
3 changed files with 83 additions and 45 deletions
54
packages/flaresolverr/chromedriver_path.patch
Normal file
54
packages/flaresolverr/chromedriver_path.patch
Normal file
|
@ -0,0 +1,54 @@
|
|||
diff --git a/src/utils.py b/src/utils.py
|
||||
index 79cf6f6..fef4a68 100644
|
||||
--- a/src/utils.py
|
||||
+++ b/src/utils.py
|
||||
@@ -154,47 +154,8 @@ def get_webdriver(proxy: dict = None) -> WebDriver:
|
||||
else:
|
||||
start_xvfb_display()
|
||||
|
||||
- # if we are inside the Docker container, we avoid downloading the driver
|
||||
- driver_exe_path = None
|
||||
- version_main = None
|
||||
- if os.path.exists("/app/chromedriver"):
|
||||
- # running inside Docker
|
||||
- driver_exe_path = "/app/chromedriver"
|
||||
- else:
|
||||
- version_main = get_chrome_major_version()
|
||||
- # Fix for Chrome 115
|
||||
- # https://github.com/seleniumbase/SeleniumBase/pull/1967
|
||||
- if int(version_main) > 114:
|
||||
- version_main = 114
|
||||
- if PATCHED_DRIVER_PATH is not None:
|
||||
- driver_exe_path = PATCHED_DRIVER_PATH
|
||||
-
|
||||
- # detect chrome path
|
||||
- browser_executable_path = get_chrome_exe_path()
|
||||
-
|
||||
- # downloads and patches the chromedriver
|
||||
- # 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, 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)
|
||||
- if PATCHED_DRIVER_PATH != driver.patcher.executable_path:
|
||||
- shutil.copy(driver.patcher.executable_path, PATCHED_DRIVER_PATH)
|
||||
-
|
||||
- # clean up proxy extension directory
|
||||
- if proxy_extension_dir is not None:
|
||||
- shutil.rmtree(proxy_extension_dir)
|
||||
-
|
||||
- # selenium vanilla
|
||||
- # options = webdriver.ChromeOptions()
|
||||
- # options.add_argument('--no-sandbox')
|
||||
- # options.add_argument('--window-size=1920,1080')
|
||||
- # options.add_argument('--disable-setuid-sandbox')
|
||||
- # options.add_argument('--disable-dev-shm-usage')
|
||||
- # driver = webdriver.Chrome(options=options)
|
||||
+ driver = uc.Chrome(options=options, driver_executable_path="@chromedriver_path@",
|
||||
+ windows_headless=windows_headless)
|
||||
|
||||
return driver
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue