使用https 双向验证
代码应该系酱:
代码语言:javascript复制import ssl
import aiohttp
sslcontext = ssl.create_default_context(cafile='/path_to_client_root_ca')
sslcontext.load_cert_chain(certfile=cert_file, keyfile=client_key)
conn = aiohttp.TCPConnector(ssl_context=sslcontext)
async with aiohttp.ClientSession(connector=conn) as session:
pass
尚未测试。等待使用。
使用
session
代码语言:javascript复制async with aiohttp.ClientSession() as session:
async with session.get('https://api.github.com/events') as resp:
print(resp.status)
print(await resp.text())
简单使用
代码语言:javascript复制async with aiohttp.request('GET', 'https://api.github.com/events') as resp:
json = await resp.json()
print(json)