PhantomJS提供了
resourceTimeout,可能适合您的需求。我在这里引用文档
(以毫秒为单位)定义了超时,在此超时之后,所请求的任何资源将停止尝试并继续处理页面的其他部分。onResourceTimeout回调将在超时时被调用。
因此,在Ruby中,您可以执行以下操作
require 'selenium-webdriver'capabilities = Selenium::WebDriver::Remote::Capabilities.phantomjs("phantomjs.page.settings.resourceTimeout" => "5000")driver = Selenium::WebDriver.for :phantomjs, :desired_capabilities => capabilities我相信Python,就像(未经测试,仅提供逻辑,您是Python开发人员,希望您能弄清楚)
driver = webdriver.PhantomJS(desired_capabilities={'phantomjs.page.settings.resourceTimeout': '5000'})


