session = requests.Session()
session.get("https://hedefurl.com")
cookie = response.cookies.get_dict()
with open('filename', 'w', encoding='utf8') as json_file:
json.dump(cookie, json_file, ensure_ascii=False)
kod:
session = requests.Session()
session.proxies.update(proxies)
session.headers.update(headers)
response = session.post(endpoint, data=post_data, timeout=10)
cookie = response.cookies.get_dict()
with open('cache/cookies.txt', 'w', encoding='utf8') as json_file:
json.dump(cookie, json_file, ensure_ascii=False)
ress = [response.text]
print(ress)
çıktı:
File "Documents/login.py", line 45
json.dump(cookie, json_file, ensure_ascii=False)
^^^^
IndentationError: expected an indented block after 'with' statement on line 43
>>>