pjscrape の最初のスクリプトを書きましたが、実行速度が非常に遅いことがわかりました。私は pjscrape と phantomjs の両方に慣れていないので、どちらが原因かわかりません。
localhost からファイルを読み込んでいるので、ボトルネックは間違いなく転送にありません。
私のconfig.jsスクリプトは次のようになります。
pjs.addSuite({
url: 'http://localhost/file.html'.
scraper: function() {
var people = $('table.person');
var results = [];
$.each(people, function() {
var $this = $(this);
results.push({
firstName: $this.find('.firstName').text(),
lastName: $this.find('.lastName').text(),
age: $this.find('.age').text()
});
}
return results;
}
}
次に、こちらのコマンド ライン手順を使用して PhantomJS を実行します。
~> phantomjs pjscrape.js config.js
Chrome で同じコード (スクレーパー function() のみ) を実行すると、すぐに実行されます。phantomjs/pjscrape では、30 秒ほどかかります。
遅さの原因は何ですか?
このDOMスクリーンスクレイピングを行うより良い方法はありますか? 多分nodejsソリューション?