【问题标题】:Refresh webpage if got connection time out selenium python如果连接超时硒python,请刷新网页
【发布时间】:2021-04-15 01:08:30
【问题描述】:

我正在使用代理轮换,有时可能会发生其中一个随机无法正常工作,我得到"ERR_TIMED_OUT" 启用以访问服务器并且脚本在没有继续的情况下刚刚崩溃,是否可以在 silenium 中自动刷新网页?发生(因此代理将旋转)。我考虑过捕获异常然后 driver.refresh() 但我如何在不尝试的情况下捕获整个代码 - 除了每条指令?还有其他解决方案吗?谢谢!

【问题讨论】:

    标签: python selenium exception timeout


    【解决方案1】:

    您可以使用 event_firing_webdriver: https://www.selenium.dev/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.event_firing_webdriver.html

    你可以装饰方法 get() 并执行 try 除了那里(超时异常刷新)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-22
      • 1970-01-01
      • 2015-10-15
      • 1970-01-01
      • 2012-03-26
      • 1970-01-01
      相关资源
      最近更新 更多