diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-01-29 18:14:46 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-01-29 18:14:46 +0100 |
commit | a28bab938704a15c825c1b45a8983c72e8c90ace (patch) | |
tree | 0a3ee26bb1f9e7bf7c1a5a739ed59015248acbfb /g4f/requests.py | |
parent | Merge pull request #1523 from u66u/which-webdriver (diff) | |
download | gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar.gz gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar.bz2 gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar.lz gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar.xz gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar.zst gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/requests.py | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/g4f/requests.py b/g4f/requests.py index 275e108b..d7b5996b 100644 --- a/g4f/requests.py +++ b/g4f/requests.py @@ -7,13 +7,13 @@ try: from .requests_curl_cffi import StreamResponse, StreamSession has_curl_cffi = True except ImportError: - Session = type + from typing import Type as Session from .requests_aiohttp import StreamResponse, StreamSession has_curl_cffi = False from .webdriver import WebDriver, WebDriverSession, bypass_cloudflare, get_driver_cookies 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: """ @@ -36,22 +36,14 @@ def get_args_from_browser(url: str, webdriver: WebDriver = None, proxy: str = No return { 'cookies': cookies, 'headers': { - 'accept': '*/*', - "accept-language": "en-US", - "accept-encoding": "gzip, deflate, br", - 'authority': parse.netloc, - 'origin': f'{parse.scheme}://{parse.netloc}', - 'referer': url, - "sec-ch-ua": "\"Google Chrome\";v=\"121\", \"Not;A=Brand\";v=\"8\", \"Chromium\";v=\"121\"", - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": "Windows", - 'sec-fetch-dest': 'empty', - 'sec-fetch-mode': 'cors', - 'sec-fetch-site': 'same-origin', - 'user-agent': user_agent, + **DEFAULT_HEADERS, + 'Authority': parse.netloc, + 'Origin': f'{parse.scheme}://{parse.netloc}', + 'Referer': url, + 'User-Agent': user_agent, }, } - + def get_session_from_browser(url: str, webdriver: WebDriver = None, proxy: str = None, timeout: int = 120) -> Session: if not has_curl_cffi: raise MissingRequirementsError('Install "curl_cffi" package') |