Отправляю запрос, цель получить ответ уже с авторизированным аккаунтом, но в ошибку я получаю это:
Traceback (most recent call last):
File "C:\Users\-\AppData\Local\Programs\Thonny\lib\ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "C:\Users\-\Downloads\code .py", line 17
print(cookies)
%
IndentationError: unexpected indent
def cookies_from_file(file, search):
try:
cookies_dict = {}
with open(file, encoding="utf-8") as file:
cookies_dic = file.read().split("\n")
for i in range(0, len(cookies_dic)):
if cookies_dic[i].count(search) > 0:
cookies_dict[cookies_dic[i].split()[-2]] = cookies_dic[i].split()[-1]
return cookies_dict
except Exception as e:
print(e)
cookies = cookies_from_file("Opera GX_Unknown.txt", ".battle.net")
print(cookies)
headers = {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "ru,en;q=0.9",
"Cache-Control": "max-age=0",
"Connection": "keep-alive",
"Host": "eu.shop.battle.net",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.86 YaBrowser/21.3.0.663 Yowser/2.5 Safari/537.36"
}
response = requests.get("https://eu.shop.battle.net/ru-ru", headers=headers, cookies=cookies, allow_redirects=True)
print(response.text)