【发布时间】:2021-05-13 23:10:01
【问题描述】:
我在 python 中使用 selenium,我的 chromedriver 和 chrome.exe 是 ver90.0
我遇到了一个问题,即一旦发生超时错误,脚本就会停止,问题是它总是会发生,有时在几个小时内,有时在几分钟内。
它会显示类似:
selenium.common.exceptions.timeoutexception: message: timeout: timed out receiving message from renderer: -0.014
当发生这种情况时,我看到网页通常正在加载并且它基本上无法加载导致发生错误。
有没有办法忽略这个错误,基本上让脚本要么刷新,要么继续加载到列表中的下一个网页。示例代码如下所示:
while True:
driver.get(thislist[i])
if .......:
i = i + 1
我尝试了很多修复,但都没有奏效。我尝试使用 beta chrome.exe 和 chrome webdriver ver 91.0。我还尝试了包含 chrome_options 并且还尝试了一些不在此代码中的标头,但我总是收到超时错误。我之前问过这个问题几次,但没有一个有效的解决方法。
chrome_options.add_argument('--enable-automation')
chrome_options.add_argument('--lang=en')
chrome_options.add_argument("window-size=1920,1080")
chrome_options.headless = True
chrome_options.add_experimental_option ("debuggerAddress", "localhost:8989")
driver = webdriver.Chrome(executable_path='C:/Webdriver/chromedriver', chrome_options=chrome_options)
【问题讨论】: