使用Selenium 4.14.0与Python 3.11.4爬取网站遇ERR_SSL_PROTOCOL_ERROR报错求助
解决Selenium中net::ERR_SSL_PROTOCOL_ERROR的方法
补充SSL忽略相关参数
现有参数不足以覆盖所有SSL协议限制,添加以下参数增强忽略能力:
options = webdriver.ChromeOptions() options.add_argument('--lang=en') options.add_argument('--allow-insecure-localhost') options.add_argument('--ignore-certificate-errors') # 新增参数 options.add_argument('--ignore-ssl-errors') options.add_argument('--allow-running-insecure-content') options.add_argument('--disable-web-security') options.add_argument('--disable-features=VizDisplayCompositor')
匹配ChromeDriver与Chrome版本
Chrome版本为119.0.6045.123,需确保ChromeDriver版本完全对应:
- 手动下载对应版本的ChromeDriver
- 在代码中指定驱动路径:
from selenium import webdriver from selenium.webdriver.chrome.service import Service options = webdriver.ChromeOptions() # 配置上述所有参数 service = Service('/path/to/your/chromedriver') driver = webdriver.Chrome(service=service, options=options)
调整Chrome浏览器版本
若上述操作无效,尝试将Chrome浏览器降级到118版本或升级至最新稳定版,部分特定版本存在SSL协议兼容性bug。
检查目标网站SSL配置
手动用Chrome访问目标网站,查看证书详情:
- 确认网站支持的SSL协议版本(如TLS 1.2/1.3)是否与当前Chrome版本兼容
- 排查网站是否存在证书链不完整等问题
内容的提问来源于stack exchange,提问作者Mahdi
相关产品推荐
相关产品推荐

