Webページをスクレイピングしてる時、HTMLじゃなくてJavaScriptの変数をのぞきたい事が稀によくある。 インストール brew install phantomjs document.titleを取得 page_title.js var url = phantom.args[0] || 'http://shokai.org'; page = new WebPage(); page.open(url, function(stat){ if(!stat){ phantom.exit(); } else{ var title = page.evaluate(function(){ return document.title; }); console.log(title); phantom.exit(); } }); 実行 phantomjs page_title.js http://go