错误提示
- requests.exceptions.SSLError: HTTPSConnectionPool(host=’www.yapt.edu.cn’, port=443): Max retries exceeded with url: /index/xyyw.htm (Caused by SSLError(SSLError(1, ‘[SSL: DH_KEY_TOO_SMALL] dh key too small (_ssl.c:1007)’)))
解决 方法1 添加默认密码字符串
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS += 'HIGH:!DH:!aNULL'
#
#
方法2 降低版本
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS = 'DEFAULT:@SECLEVEL=1'
方法3 使用httpx插件
import httpx
httpx._config.DEFAULT_CIPHERS += ":ALL:@SECLEVEL=1"
with httpx.Client() as client:
resp = client.get(url)
return resp.text