Python 使用PhantomJs拒绝连接
我在python中使用Selenium+PhantomJS驱动程序。它的配置如下:Python 使用PhantomJs拒绝连接,python,selenium,phantomjs,Python,Selenium,Phantomjs,我在python中使用Selenium+PhantomJS驱动程序。它的配置如下: desired_cap = { 'phantomjs.page.settings.loadImages' : False, 'phantomjs.page.settings.resourceTimeout' : 10000, 'phantomjs.page.settings.userAgent' : '...' } self.driver = webdriver.
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分钟内(2秒钟内获得1次)一切正常,之后我会得到错误:
<urlopen error [Errno 111] Connection refused>
所有内容都在本地计算机上运行。当禁用加载图像时,问题似乎出在:
'phantomjs.page.settings.loadImages' : False
所以,当我启用图像加载问题消失
'phantomjs.page.settings.loadImages' : False