python - aiohttp showing 403 error but requests.get giving 200 response - Stack Overflow
I'm using aiohttp to asynchronously retrieve a price from a url. Previously, I used requests.get for synchronous reading. I can successfully fetch the data with requests.get, but the same url gives a 403 error when I try to do it with aiohttp. I'm trying to figure out what the problem might be, but so far I'm not having any luck.
import aiohttp
import asyncio
import requests
url = '/?search%5Bfilter_float_price:to%5D=1500'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36',
'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*',
'Connection': 'keep-alive',
}
resp = requests.get(url=url, headers=headers)
print(resp.status_code)
#Output 200
async def main():
async with aiohttp.ClientSession() as session:
async with session.get(url, headers=headers) as response:
print(response.status)
asyncio.run(main())
#Output 403
I expect to get 200 status in both cases
最新文章
- 2015年形成的计算机发展趋势 Windows10依然强势
- 都想取代PC 这些产品究竟还欠缺什么?
- How to upload wordpress from local to Godaddy wordpress hosting? - Stack Overflow
- javascript - How to check if a track is already added to a WebRTC peer connection before adding it? - Stack Overflow
- flutter - App Name Not Updating in Android Recent Apps View Despite Manifest and Strings Configuration - Stack Overflow
- machine learning - Cannot import name 'T2TViTModel' from 'transformers' - Stack Overflow
- python - NaN values in Pandas are not being filled by the interpolate function when it's applied to a full dataframe - S
- How to switch flutter project on Android studio 2021.2.1 from my windows machine to android studio ladybug on my mac through Git
- python - invoke matplotlib toolbar keeping custom views history - Stack Overflow
- python - How to display only the tags translated into the corresponding language on a multilingual site? - Stack Overflow
- i tried to get read edit manage storage in android java and output permission denied and not found in device setting - Stack Ove
- reactjs - input forms not alligning right inside a React app - Stack Overflow
- Deploying Angular App on Azure SWA with SCSS Issues - Stack Overflow
- python - sympy integration with quotient and cot(x) not getting simplifed results - Stack Overflow
- Blockchain record extraction - Stack Overflow
- sockets - PICO WMicropython websocket client can't send to PHP websocket properly - Stack Overflow
- Swift Predicate: Fatal Error Keypaths With Multiple Components - Stack Overflow