Answer the question
In order to leave comments, you need to log in
Why is the result of a request through Aiohttp incorrect, but everything works through request?
import requests
burp0_url = "https://m.avito.ru/api/11/items?key=1&priceMin=1&priceMax=9999999&owner[]=private&sort=date&query=iphone&page=1&display=list&limit=30"
burp0_headers = {
"User-Agent": "Mozilla/5.0 (Linux; Android 11; SAMSUNG SM-G973U) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/14.2 Chrome/87.0.4280.141 Mobile Safari/537.36",
"Accept": "application/json, text/plain, */*", "Accept-Language": "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3",
"Accept-Encoding": "gzip, deflate", "Content-Type": "application/json;charset=utf-8", "Dnt": "1",
"Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-origin", "Te": "trailers"}
r = requests.get(burp0_url, headers=burp0_headers).json()
print(r)
{'error': {'code': 403, 'message': 'Неизвестный ключ'}}
url = "https://m.avito.ru/api/11/items?key=1&priceMin=1&priceMax=9999999&owner[]=private&sort=date&query=iphone&page=1&display=list&limit=30"
headers = {
"User-Agent": "Mozilla/5.0 (Linux; Android 11; SAMSUNG SM-G973U) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/14.2 Chrome/87.0.4280.141 Mobile Safari/537.36",
"Accept": "application/json, text/plain, */*", "Accept-Language": "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3",
"Accept-Encoding": "gzip, deflate", "Content-Type": "application/json;charset=utf-8", "Dnt": "1",
"Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-origin", "Te": "trailers"}
async with aiohttp.ClientSession() as cs:
async with cs.get(url, headers=headers) as req:
items = await req.json()
print(items)
{'code': 403, 'error': {'message': 'Доступ с вашего IP-адреса временно ограничен', 'link': 'ru.avito://1/info/ipblock/show'}}
although this is not the case, it works through Request, but not through Aiohttp, I can’t understand why, everything is exactly the same as in requests, but it doesn’t work
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question