diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-02-23 11:33:38 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-02-23 11:33:38 +0100 |
commit | 51264fe20cda57eff47ac9a386edb3563eac4568 (patch) | |
tree | 29233c3c384ebc8cc493e68842aa0dcff499cd49 /g4f/requests | |
parent | Add missing file (diff) | |
download | gpt4free-51264fe20cda57eff47ac9a386edb3563eac4568.tar gpt4free-51264fe20cda57eff47ac9a386edb3563eac4568.tar.gz gpt4free-51264fe20cda57eff47ac9a386edb3563eac4568.tar.bz2 gpt4free-51264fe20cda57eff47ac9a386edb3563eac4568.tar.lz gpt4free-51264fe20cda57eff47ac9a386edb3563eac4568.tar.xz gpt4free-51264fe20cda57eff47ac9a386edb3563eac4568.tar.zst gpt4free-51264fe20cda57eff47ac9a386edb3563eac4568.zip |
Diffstat (limited to 'g4f/requests')
-rw-r--r-- | g4f/requests/__init__.py | 11 |
1 files changed, 9 insertions, 2 deletions
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) |