硒壁虎驱动程序无法从大型页面保存页面源

时间:2018-07-18 05:51:17

标签: python selenium selenium-webdriver geckodriver

driver = webdriver.Firefox  # geckodriver 0.20.1
html_page = driver.page_source

在大小小于120 MB的网页上调用driver.page_source时,一切都会顺利进行。但是,当页面增长到超过120MB时,我得到以下回溯:

Traceback (most recent call last):
File "program.py", line 251, in <module>
autosave_page = browser.page_source
File "/usr/lib/python3/dist-packages/selenium/webdriver/remote/webdriver.py", line 587, in page_source
return self.execute(Command.GET_PAGE_SOURCE)['value']
File "/usr/lib/python3/dist-packages/selenium/webdriver/remote/webdriver.py", line 311, in execute
self.error_handler.check_response(response)
File "/usr/lib/python3/dist-packages/selenium/webdriver/remote/errorhandler.py", line 237, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: 
Message: [Exception...  "Failure"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  
location: "JS frame :: chrome://marionette/content/proxy.js :: sendReply_ :: line 276"  data: no]

我可以通过延长超时时间来解决此问题吗?

感谢您提供有关如何防止这种情况发生的建议。

0 个答案:

没有答案