所以我在 Python 中使用 Selenium Wire 来浏览网站,目前我的代码失败并出现以下错误
错误:ssl_client_socket_impl.cc(959)] 握手失败;返回 -1,SSL 错误代码 1,net_error -100'''
当我收到此错误时,Selenium 似乎与 Internet 断开连接,因此后续的点击和交互不起作用。我在网上看了一下,明白我需要传递以下参数(有道理,但如果我错了,请纠正我)
options.add_argument('--ignore-certificate-errors-spki-list')
options.add_argument('--ignore-ssl-errors').
Run Code Online (Sandbox Code Playgroud)
我已经有以下使用代理服务器的代码,但我不确定如何将上述参数传递到我当前的 Selenium 选项中,并且代理选项已经到位。我希望这是有道理的?!
(出于安全原因obvs,我已经更改了我的代理服务器详细信息)。
谢谢!!!!!!
import selenium
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
url = 'http://www.whatsmyipaddress.com'
from seleniumwire import webdriver
options = {
'proxy': {
'http': 'http://myusername:password@myproxyserver.com:123456',
'https': 'http://myusername:password@myproxyserver.com:123456',
'no_proxy': 'localhost,127.0.0.1' # excludes
}
}
driver = webdriver.Chrome(executable_path=r"C:\Chrome\chromedriver.exe",
seleniumwire_options=options)
driver.get(url=url)
Run Code Online (Sandbox Code Playgroud)