学习爬虫的路上真不是一帆风顺,总是遇到各种各样的问题,在这个系统正常,换一个系统就出问题,在CentOS7,一切正常。这不,今天练习异步http请求aiohttp模块,操作系统是mac ,python3.8,使用环境pycharm2020.1。利用异步协程语句:
async with aiohttp.ClientSession() as session:
报错:“ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host kr.shanghai-jiuxin.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')]”
解决办法:
导入TCPConnector模块
from aiohttp import TCPConnector
然后在async with aiohttp.ClientSession(connector=TCPConnector(ssl=False)) as session:
这样就避免ssl证书验证报错。