From 51264fe20cda57eff47ac9a386edb3563eac4568 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Fri, 23 Feb 2024 11:33:38 +0100 Subject: Add GeminiPro API provider Set min version for undetected-chromedriver Add api_key to the new client --- g4f/requests/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'g4f/requests') diff --git a/g4f/requests/__init__.py b/g4f/requests/__init__.py index d278ffaf..83176557 100644 --- a/g4f/requests/__init__.py +++ b/g4f/requests/__init__.py @@ -15,7 +15,13 @@ from ..webdriver import WebDriver, WebDriverSession, bypass_cloudflare, get_driv from ..errors import MissingRequirementsError from .defaults import DEFAULT_HEADERS -def get_args_from_browser(url: str, webdriver: WebDriver = None, proxy: str = None, timeout: int = 120) -> dict: +def get_args_from_browser( + url: str, + webdriver: WebDriver = None, + proxy: str = None, + timeout: int = 120, + do_bypass_cloudflare: bool = True +) -> dict: """ Create a Session object using a WebDriver to handle cookies and headers. @@ -29,7 +35,8 @@ def get_args_from_browser(url: str, webdriver: WebDriver = None, proxy: str = No Session: A Session object configured with cookies and headers from the WebDriver. """ with WebDriverSession(webdriver, "", proxy=proxy, virtual_display=False) as driver: - bypass_cloudflare(driver, url, timeout) + if do_bypass_cloudflare: + bypass_cloudflare(driver, url, timeout) cookies = get_driver_cookies(driver) user_agent = driver.execute_script("return navigator.userAgent") parse = urlparse(url) -- cgit v1.2.3