Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
Headers also need to change (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry-Jing committed Mar 13, 2023
1 parent 6a37cab commit 20a84cb
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/EdgeGPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
"accept": "application/json",
"accept-language": "en-US,en;q=0.9",
"content-type": "application/json",
"sec-ch-ua": '"Not_A Brand";v="99", "Microsoft Edge";v="109", "Chromium";v="109"',
"sec-ch-ua": '"Not_A Brand";v="99", "Microsoft Edge";v="110", "Chromium";v="110"',
"sec-ch-ua-arch": '"x86"',
"sec-ch-ua-bitness": '"64"',
"sec-ch-ua-full-version": '"109.0.1518.78"',
"sec-ch-ua-full-version-list": '"Not_A Brand";v="99.0.0.0", "Microsoft Edge";v="109.0.1518.78", "Chromium";v="109.0.5414.120"',
'sec-ch-ua-full-version-list': '"Chromium";v="110.0.5481.192", "Not A(Brand";v="24.0.0.0", "Microsoft Edge";v="110.0.1587.69"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-model": "",
"sec-ch-ua-platform": '"Windows"',
Expand All @@ -49,6 +49,28 @@
"x-forwarded-for": FORWARDED_IP,
}

HEADERS_INIT_CONVER = {
'authority': 'edgeservices.bing.com',
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
"accept-language": "en-US,en;q=0.9",
'cache-control': 'max-age=0',
'sec-ch-ua': '"Chromium";v="110", "Not A(Brand";v="24", "Microsoft Edge";v="110"',
'sec-ch-ua-arch': '"x86"',
'sec-ch-ua-bitness': '"64"',
'sec-ch-ua-full-version': '"110.0.1587.69"',
'sec-ch-ua-full-version-list': '"Chromium";v="110.0.5481.192", "Not A(Brand";v="24.0.0.0", "Microsoft Edge";v="110.0.1587.69"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-model': '""',
'sec-ch-ua-platform': '"Windows"',
'sec-ch-ua-platform-version': '"15.0.0"',
'sec-fetch-dest': 'document',
'sec-fetch-mode': 'navigate',
'sec-fetch-site': 'none',
'sec-fetch-user': '?1',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.69',
'x-edge-shopping-flag': '1',
}

class NotAllowedToAccess(Exception):
pass
Expand Down Expand Up @@ -178,7 +200,7 @@ def __init__(self, cookiePath: str = "", cookies: Optional[dict] = None) -> None
response = self.session.get(
url,
timeout=30,
headers=HEADERS,
headers=HEADERS_INIT_CONVER,
)
if response.status_code != 200:
print(f"Status code: {response.status_code}")
Expand Down

0 comments on commit 20a84cb

Please sign in to comment.