【发布时间】:2015-11-27 06:41:21
【问题描述】:
我在 python 中使用 Selenium + PhantomJS 驱动程序。它的配置如下:
desired_cap = {
'phantomjs.page.settings.loadImages' : False,
'phantomjs.page.settings.resourceTimeout' : 10000,
'phantomjs.page.settings.userAgent' : '...'
}
self.driver = webdriver.PhantomJS(desired_capabilities=desired_cap)
self.driver.set_window_size(1024, 768)
self.driver.set_page_load_timeout(10)
比在循环中我请求一些页面使用:
self.driver.get('page-url')
一切正常运行大约 5 分钟(约 1 分钟内 2 秒),在那之后我得到错误:
<urlopen error [Errno 111] Connection refused>
它不仅出现在 get 方法中,而且出现在从 self.driver 调用的任何方法中。我认为与phantomjs 实例的连接由于某种原因而断开,并且对象无法向其发送命令。
phantomjs --version
2.0.1-development
uname -a
Linux wincode 3.16.0-38-generic #52~14.04.1-Ubuntu SMP Fri May 8 09:43:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
一切都在本地机器上运行。
【问题讨论】: