我有一个与requests
配合良好的POST请求,但是使用aiohttp客户端时服务器将其误解。有没有办法记录来自aiohttp客户端的原始POST请求以进行比较?
对于上下文,这就是我使用requests
的方式:
url = 'https://www.places4students.com/Places/PropertyListings?SchoolID=FzhtQRDGtSU='
for next_page in range(4):
soup = BeautifulSoup(requests.request(
'POST', url,
data={'__EVENTARGUMENT': f'Page${next_page}'},
cookies={'Places4StudentDisclaimer': 'Agree'}
).content, 'html.parser')
这是代码的aiohttp客户端版本:
async with aiohttp.ClientSession(connector=connector) as session:
async with session.request(
'POST', url,
data={'__EVENTARGUMENT': f'Page${next_page}'},
cookies={'Places4StudentDisclaimer': 'Agree'}
) as response:
content = await response.text()
soup = BeautifulSoup(content, 'html.parser')