【发布时间】:2021-08-08 07:02:03
【问题描述】:
我正在使用 aiohttp 客户端向 URL 发送请求并收集重定向的 URL。
在我的例子中,重定向的 URL 中包含 Unicode 文本。我希望它保持原样。
例如,实际重定向的 URL 是 example.com/förderprojekte-e-v,但 aiohttp 客户端会自动对其进行编码并返回给我 example.com/f\udcf6rderprojekte-e-v .
如何使 aiohttp 禁用重定向 url 的自动编码。
对于请求模块,this 解决方案有效,但我需要 aiohttp 的帮助。
我的代码:
async fetch(url):
#url = 'https://www.example.com/test/123'
async with client.get(url, allow_redirects = True ) as resp:
html = await resp.read()
redir_url = str(resp.url)
#example.com/f\udcf6rderprojekte-e-v
或者至少告诉我如何将 \udcf6 转换为 ö
【问题讨论】:
标签: python python-requests urlencode aiohttp