PhantomJS
もはや説明するまでもないですが、PhantomJS とは WebKit ベースの Headless な Webブラウザ です。こいつを Ubuntu で使おうとしたのですが……ドハマりしました。
ハマった理由 : apt-get で入れた
これやっちゃだめです。もうエラーの嵐です。
# apt-get install -y phantomjs # phantomjs test.js QXcbConnection: Could not connect to display PhantomJS has crashed.
正解 : npm で入れる
npm で入れましょう。
# npm install -g phantomjs
nodejs-legacy が入っていない場合は入れておいてあげましょう。
# apt-get install -y nodejs nodejs-legacy
補足
PhantomJS は deprecated なので Headless Chrome などに移行するのがよいでしょう。