summaryrefslogtreecommitdiffstats
path: root/g4f/requests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--g4f/requests/__init__.py11
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)