Spaces:
Paused
Paused
File size: 1,601 Bytes
f05e49d 21f117b dd37946 855fab6 c05a7fe 21f117b c05a7fe f05e49d c05a7fe a1801ab 855fab6 a1801ab dd37946 21f117b a1801ab 1f691c1 f05e49d c05a7fe a1801ab f05e49d c05a7fe 3eecc54 f05e49d 3eecc54 f05e49d 3eecc54 f05e49d 21f117b f05e49d c05a7fe |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
import requests
from pprint import pprint
from utils.enver import enver
from networks import ConversationCreateHeadersConstructor
class ConversationCreator:
conversation_create_url = "https://www.bing.com/turing/conversation/create"
def __init__(self, cookies: dict = {}):
self.cookies = cookies
def construct_cookies(self):
pass
def construct_headers(self):
# New Bing 封锁原理探讨 #78
# https://github.com/weaigc/bingo/issues/78
self.request_headers = ConversationCreateHeadersConstructor().request_headers
def create(self):
self.construct_cookies()
self.construct_headers()
enver.set_envs(proxies=True)
self.response = requests.get(
self.conversation_create_url,
headers=self.request_headers,
proxies=enver.requests_proxies,
)
try:
self.response_data = self.response.json()
except:
print(self.response.text)
raise Exception(
f"x Failed to create conversation: {self.response.status_code}"
)
self.response_headers = self.response.headers
pprint(self.response_data)
# These info would be used in ConversationConnector
self.sec_access_token = self.response_headers[
"x-sydney-encryptedconversationsignature"
]
self.client_id = self.response_data["clientId"]
self.conversation_id = self.response_data["conversationId"]
if __name__ == "__main__":
creator = ConversationCreator()
creator.create()
|