diff options
author | Tekky <98614666+xtekky@users.noreply.github.com> | 2023-12-02 21:50:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-02 21:50:26 +0100 |
commit | 045d4073ee55f8bc08a2fbbf90877a01c24df5ab (patch) | |
tree | 0ba2ad0cb7fffd5b4882e2dad25bea1b6f984e33 /g4f/webdriver.py | |
parent | Merge pull request #1301 from xtekky/go (diff) | |
parent | Add get_session_from_browser as cloudflare bypass (diff) | |
download | gpt4free-045d4073ee55f8bc08a2fbbf90877a01c24df5ab.tar gpt4free-045d4073ee55f8bc08a2fbbf90877a01c24df5ab.tar.gz gpt4free-045d4073ee55f8bc08a2fbbf90877a01c24df5ab.tar.bz2 gpt4free-045d4073ee55f8bc08a2fbbf90877a01c24df5ab.tar.lz gpt4free-045d4073ee55f8bc08a2fbbf90877a01c24df5ab.tar.xz gpt4free-045d4073ee55f8bc08a2fbbf90877a01c24df5ab.tar.zst gpt4free-045d4073ee55f8bc08a2fbbf90877a01c24df5ab.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/webdriver.py (renamed from g4f/Provider/webdriver.py) | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/g4f/Provider/webdriver.py b/g4f/webdriver.py index da3b13ed..288eed0e 100644 --- a/g4f/Provider/webdriver.py +++ b/g4f/webdriver.py @@ -2,20 +2,9 @@ from __future__ import annotations import time from platformdirs import user_config_dir -try: - from selenium.webdriver.remote.webdriver import WebDriver -except ImportError: - class WebDriver(): - pass -try: - from undetected_chromedriver import Chrome, ChromeOptions -except ImportError: - class Chrome(): - def __init__(): - raise RuntimeError('Please install the "undetected_chromedriver" package') - class ChromeOptions(): - def add_argument(): - pass +from selenium.webdriver.remote.webdriver import WebDriver +from undetected_chromedriver import Chrome, ChromeOptions + try: from pyvirtualdisplay import Display has_pyvirtualdisplay = True @@ -27,12 +16,13 @@ def get_browser( headless: bool = False, proxy: str = None, options: ChromeOptions = None -) -> Chrome: +) -> WebDriver: if user_data_dir == None: user_data_dir = user_config_dir("g4f") + if not options: + options = ChromeOptions() + options.add_argument("window-size=1920,1080"); if proxy: - if not options: - options = ChromeOptions() options.add_argument(f'--proxy-server={proxy}') return Chrome(options=options, user_data_dir=user_data_dir, headless=headless) |