错误提示

  • ssl_client_socket_impl.cc(975)] handshake failed; returned -1, SSL error code 1, net_error -103
解决方案
chrome_options = webdriver.ChromeOptions()

# 忽略证书错误
chrome_options.add_argument('--ignore-certificate-errors')
# 忽略 Bluetooth: bluetooth_adapter_winrt.cc:1075 Getting Default Adapter failed. 错误
chrome_options.add_experimental_option('excludeSwitches', ['enable-automation'])
# 忽略 DevTools listening on ws://127.0.0.1... 提示
chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])

chrome启动失败报错:

  • /opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed
解决办法:
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')  # 浏览器不提供可视化页面. linux下如果系统不支持可视化不加这条会启动失败
chrome_options.add_argument('--no-sandbox')  # 解决DevToolsActivePort文件不存在的报错
chrome_options.add_argument('--disable-dev-shm-usage')   #可以不加这一条
browser = webdriver.Chrome(service=Service("driver/chromedriver"), options=chrome_options)

Edge错误:

  • microsoft-edge is no longer running, so msedgedriver is assuming
_options = webdriver.EdgeOptions()

#
_options.add_argument('--headless')  # 浏览器不提供可视化页面. linux下如果系统不支持可视化不加这条会启动失败
_options.add_argument('--no-sandbox')  # 解决DevToolsActivePort文件不存在的报错
webdriver.Edge(service=Service("driver/msedgedriver"), options=_options)