diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2023-12-06 09:35:36 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2023-12-06 09:35:36 +0100 |
commit | 3576dee75a1623aa2385b6afe8b922ad5affca26 (patch) | |
tree | f54f68590875e4e67adaab03139f18167ffc7fa1 /g4f/webdriver.py | |
parent | Add get_session_from_browser as cloudflare bypass (diff) | |
download | gpt4free-3576dee75a1623aa2385b6afe8b922ad5affca26.tar gpt4free-3576dee75a1623aa2385b6afe8b922ad5affca26.tar.gz gpt4free-3576dee75a1623aa2385b6afe8b922ad5affca26.tar.bz2 gpt4free-3576dee75a1623aa2385b6afe8b922ad5affca26.tar.lz gpt4free-3576dee75a1623aa2385b6afe8b922ad5affca26.tar.xz gpt4free-3576dee75a1623aa2385b6afe8b922ad5affca26.tar.zst gpt4free-3576dee75a1623aa2385b6afe8b922ad5affca26.zip |
Diffstat (limited to 'g4f/webdriver.py')
-rw-r--r-- | g4f/webdriver.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/g4f/webdriver.py b/g4f/webdriver.py index 288eed0e..f0fa1fba 100644 --- a/g4f/webdriver.py +++ b/g4f/webdriver.py @@ -4,6 +4,8 @@ import time from platformdirs import user_config_dir from selenium.webdriver.remote.webdriver import WebDriver from undetected_chromedriver import Chrome, ChromeOptions +import os.path +from . import debug try: from pyvirtualdisplay import Display @@ -19,12 +21,16 @@ def get_browser( ) -> WebDriver: if user_data_dir == None: user_data_dir = user_config_dir("g4f") + if debug.logging: + print("Open browser with config dir:", user_data_dir) if not options: options = ChromeOptions() - options.add_argument("window-size=1920,1080"); if proxy: options.add_argument(f'--proxy-server={proxy}') - return Chrome(options=options, user_data_dir=user_data_dir, headless=headless) + driver = '/usr/bin/chromedriver' + if not os.path.isfile(driver): + driver = None + return Chrome(options=options, user_data_dir=user_data_dir, driver_executable_path=driver, headless=headless) class WebDriverSession(): def __init__( |