Python PhantomJS webdriver错误代码-6

Python PhantomJS webdriver错误代码-6,python,selenium,web-scraping,phantomjs,Python,Selenium,Web Scraping,Phantomjs,我正在远程服务器上运行一个Python脚本,该脚本使用PhantomJS作为Selenium中的webdriver定期抓取网页 脚本在运行数小时后意外停止,引发以下错误: Traceback (most recent call last): File "long.py", line 74, in <module> data = scrape_page_long() File "long.py", line 19, in scrape_page_long dri

我正在远程服务器上运行一个Python脚本,该脚本使用PhantomJS作为Selenium中的webdriver定期抓取网页

脚本在运行数小时后意外停止,引发以下错误:

Traceback (most recent call last):
  File "long.py", line 74, in <module>
    data = scrape_page_long()
  File "long.py", line 19, in scrape_page_long
    driver = webdriver.PhantomJS(service_args=['--ignore-ssl-errors=true', '--ssl-protocol=any'])
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/phantomjs/webdriver.py", line 52, in __init__
    self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 96, in start
    self.assert_process_still_running()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 109, in assert_process_still_running
    % (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service phantomjs unexpectedly exited. Status code was: -6 
回溯(最近一次呼叫最后一次):
文件“long.py”,第74行,在
数据=scrape_page_long()
文件“long.py”,第19行,在scrape_page_long中
driver=webdriver.PhantomJS(服务参数=['--ignore ssl errors=true','--ssl protocol=any']))
文件“/usr/local/lib/python2.7/dist packages/selenium/webdriver/phantomjs/webdriver.py”,第52行,在__
self.service.start()
文件“/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py”,第96行,开始
self.assert\u进程\u仍在运行()
文件“/usr/local/lib/python2.7/dist packages/selenium/webdriver/common/service.py”,第109行,断言进程仍在运行
%(self.path,返回\u代码)
selenium.common.exceptions.WebDriverException:消息:服务phantomjs意外退出。状态代码为:-6
起初我认为这与ssl错误有关(因此出现了参数),但我认为这似乎与ssl错误无关


您知道是什么导致了这个问题吗?

您的脚本永远无法抓取网页,因为PhantomJS在服务器上根本无法工作

如果登录到服务器并运行
phantomjs--version
,您将看到:

QXcbConnection: Could not connect to display
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.
Aborted
QXcbConnection:无法连接到显示器
幻影已经崩溃了。请阅读错误报告指南,网址为
并提交错误报告。
流产

您可以通过将
export QT_QPA_PLATFORM=offscreen
添加到用户帐户的
.bashrc
,或将
QT_QPA_PLATFORM=offscreen
添加到服务器的
/etc/environment
中来修复此问题,因为PhantomJS根本无法在服务器上工作

如果登录到服务器并运行
phantomjs--version
,您将看到:

QXcbConnection: Could not connect to display
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.
Aborted
QXcbConnection:无法连接到显示器
幻影已经崩溃了。请阅读错误报告指南,网址为
并提交错误报告。
流产
您可以通过将
export QT_QPA_PLATFORM=offscreen
添加到用户帐户的
.bashrc
,或将
QT_QPA_PLATFORM=offscreen
添加到服务器的
/etc/environment
来解决此问题