python-3.x - 将 https 代理与 aiohttp 一起使用
问题描述
我需要从 https url 获取数据。我了解到 aiohttp 不支持 https 代理。有没有办法克服这个。我已经阅读了很多以前的回复,但找不到任何东西。
async def fetch(url, session):
async with session.get(url, proxy=proxies['https']) as response:
res_dic = await response.json()
status = response.status
loop = asyncio.get_event_loop()
with ClientSession(headers=headers) as session:
loop.run_until_complete(*[asyncio.ensure_future(fetch(url, session)) for url in urls])
loop.close()
我有这样的代理
proxies = {
"https": "https://{}:{}@{}".format(username, password, proxy_url),
"http": "http://{}:{}@{}".format(username, password, proxy_url)
}
解决方案
推荐阅读
- javascript - JS:检查浏览器是否支持焦点选项
- debugging - PhpStorm Xdebug 已连接但未停止
- javascript - 在 vue 组件中使用 bootstrap-daterangepicker
- javascript - Html 表数据未按正确顺序填充
- java - 在sql日志中屏蔽9位SSN号
- node.js - 纱线升级到 1.13.0 后,内部模块 cjs 无法正常工作
- javascript - 无法从路径导入 IonicModule
- python - 如何匹配一列中的唯一元素并列出第二列中的相应值
- testing - Testcafe 在 Windows Agent 上测试 IE
- html - 如何在悬停时从上到下动画对齐?