summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/webdriver.py
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2023-12-02 05:40:07 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2023-12-02 05:40:07 +0100
commit2157ccbcdb5d781d389e24db332d2fb78b1159a9 (patch)
tree0ba2ad0cb7fffd5b4882e2dad25bea1b6f984e33 /g4f/Provider/webdriver.py
parentAdd proxy support / fix streaming (diff)
downloadgpt4free-2157ccbcdb5d781d389e24db332d2fb78b1159a9.tar
gpt4free-2157ccbcdb5d781d389e24db332d2fb78b1159a9.tar.gz
gpt4free-2157ccbcdb5d781d389e24db332d2fb78b1159a9.tar.bz2
gpt4free-2157ccbcdb5d781d389e24db332d2fb78b1159a9.tar.lz
gpt4free-2157ccbcdb5d781d389e24db332d2fb78b1159a9.tar.xz
gpt4free-2157ccbcdb5d781d389e24db332d2fb78b1159a9.tar.zst
gpt4free-2157ccbcdb5d781d389e24db332d2fb78b1159a9.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)