selenium 使用chrome_driver自动化操作谷歌浏览器 ERROR:ssl_client_socket_impl.cc

发布时间:2024-03-18 14:05:00

使用chrome_driver自动化操作Google浏览器,调试的时候没有提示,但是编译后就提示一些错误的解决方法:

[26620:28308:0318/140335.034:ERROR:ssl_client_socket_impl.cc(970)] handshake failed; returned -1, SSL error code 1, net_error -107
[26620:28308:0318/140335.034:ERROR:ssl_client_socket_impl.cc(970)] handshake failed; returned -1, SSL error code 1, net_error -107
[26620:28308:0318/140335.036:ERROR:ssl_client_socket_impl.cc(970)] handshake failed; returned -1, SSL error code 1, net_error -107
[26620:28308:0318/140335.290:ERROR:ssl_client_socket_impl.cc(970)] handshake failed; returned -1, SSL error code 1, net_error -107
[26620:28308:0318/140335.294:ERROR:ssl_client_socket_impl.cc(970)] handshake failed; returned -1, SSL error code 1, net_error -107


一. 解决方法如下

options.add_argument('verify=False') # 跳过SSL证书验证
options.add_experimental_option("excludeSwitches", ['enable-automation', 'enable-logging']) # 防止打印一些无用的日志

二. 禁用“浏览器正在被自动化程序控制的提示”的方法如下

options.add_argument('--disable-infobars')
options.add_argument('--disable-extensions')
options.add_argument('--disable-popup-blocking')

完美解决错误信息打印到CMD窗口