【问题标题】:Error with Proxy Selenium Webdriver Python : ERR_TUNNEL_CONNECTION_FAILED代理 Selenium Webdriver Python 出错:ERR_TUNNEL_CONNECTION_FAILED
【发布时间】:2021-03-28 04:15:31
【问题描述】:

我在 python 中使用 selenium 制作了一个机器人,但我有一个无法通过的错误。

我的脚本运行了 X 次,每次都使用新的代理,问题是有时代理不起作用,脚本崩溃

我有消息“无法访问此站点”或“err_connection_failed”,我尝试使用 webdriverwait,当 driver.get.url 无法连接时,执行循环尝试是否可以通过但仍被阻止网站,脚本崩溃。

Screen of error

感谢您的帮助

引发异常类(消息、屏幕、堆栈跟踪) selenium.common.exceptions.WebDriverException:消息:未知错误:net::ERR_TUNNEL_CONNECTION_FAILED (会话信息:chrome=87.0.4280.88)

【问题讨论】:

    标签: python selenium selenium-webdriver python-requests selenium-chromedriver


    【解决方案1】:

    尝试添加:

    webdriver.DesiredCapabilities.CHROME['acceptSslCerts']=True
    

    喜欢建议here。它对我有用。

    【讨论】:

      【解决方案2】:
      from selenium import webdriver
      from webdriver_manager.chrome import ChromeDriverManager
      from webdriver_manager.utils import ChromeType
      
      temp = True
      while temp:
          try:
              # Add your proxxy change code here
              driver = webdriver.Chrome(options=options)
              driver.get("https://www.google.com")
              temp = False
          except Exception as e:
              print(e)
              driver.quit()
      

      你可以添加这样的东西来捕获异常并重试直到它通过

      【讨论】:

        猜你喜欢
        • 2021-03-17
        • 1970-01-01
        • 2013-10-18
        • 2020-03-31
        • 2019-08-07
        • 2017-05-18
        • 2018-01-20
        • 1970-01-01
        • 2017-04-11
        相关资源
        最近更新 更多