2017-01-22 10 views
1

私はPhantomJSをSeleniumのWebドライバとして使用して定期的にWebページをスクレイプするリモートサーバ上でPythonスクリプトを実行しています。PhantomJS webdriverエラーコード-6

スクリプトは次のエラーを投げ、いくつかの時間のために実行した後に予期せず停止します。

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 

私はそれがSSLエラー(したがって、引数)としなければならなかったが、それは、関連するようではありません最初に考えましたおもう。

この問題の原因は何ですか?

答えて

4

PhantomJSがサーバ上で全く動作しないため、あなたのスクリプトはウェブページをスクラップすることはありません。

サーバーにログインしphantomjs --versionを実行する場合は、この表示されます:あなたは自分のユーザーアカウントの.bashrcexport QT_QPA_PLATFORM=offscreenを追加することにより、または、サーバの/etc/environmentQT_QPA_PLATFORM=offscreenを追加することによってこの問題を解決することができ

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 

を。

関連する問題