我在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)
而不是在循环中,我请求一些页面使用:
^{pr2}$每样东西都能正常工作大约5分钟(2秒钟内约1次),之后我收到错误:
<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
一切都在本地计算机上运行。在
在禁用加载图像时,memory leak of PhantomJS中似乎出现了问题:
所以当我启用图像加载时,问题就消失了。在
相关问题 更多 >
编程相关推荐