CasperJS/PhantomJS比Curl慢得多

Nyx*_*nyx 7 php screen-scraping web-scraping phantomjs casperjs

当我尝试curl www.yelp.com它需要1.1秒.但是,使用CasperJS检索页面需要一分钟!

这是正常的吗?我如何找出减慢casper/phantom的速度?我怀疑它的一些HTTP重定向,casper没有关注?

var casper = require('casper').create();
var url = 'http://www.yelp.com';

casper.start(url);
casper.then(function() {
    console.log(  this.getHTML() );
    this.exit();
});

casper.run();
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Ari*_*yat 3

你用的是Windows吗?如果是,则说明在使用自动代理时出现了神秘的网络问题。有关更多详细信息,请参阅发行说明:http://phantomjs.org/release-1.9.html

一般来说,尝试分析网络请求和响应。跟踪网络流量的一种非常简单的方法:

page.onResourceRequested = function (request) {
  console.log('Request ' + JSON.stringify(request, undefined, 4));
};
page.onResourceReceived = function (response) {
  console.log('Receive ' + JSON.stringify(response, undefined, 4));
};
Run Code Online (Sandbox Code Playgroud)

如果您想要时间等,您需要进一步调整它。请阅读有关此网络监控功能的文档。