Spaces:
Paused
Paused
File size: 1,022 Bytes
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 |
import httpx
import json
import pprint
http_proxy = "http://localhost:11111" # Replace with yours
class ConversationCreator:
conversation_create_url = "https://www.bing.com/turing/conversation/create"
def __init__(self, cookies={}):
self.cookies = cookies
self.construct_cookies()
def construct_cookies(self):
self.httpx_cookies = httpx.Cookies()
for key, val in self.cookies.items():
self.httpx_cookies.set(key, val)
def create(self, proxy=None):
self.response = httpx.get(
self.conversation_create_url,
proxies=http_proxy if proxy is None else proxy,
cookies=self.httpx_cookies,
)
self.response_content = json.loads(self.response.content.decode("utf-8"))
self.response_headers = dict(self.response.headers)
pprint.pprint(self.response_content)
# pprint.pprint(self.response_headers)
if __name__ == "__main__":
creator = ConversationCreator()
creator.create()
|