[英]CasperJS/PhantomJS much slower than Curl
When I tried curl www.yelp.com
it takes 1.1 secs. 当我尝试
curl www.yelp.com
时需要1.1秒。 However retrieving the page using CasperJS takes over a minute! 但是,使用CasperJS检索页面需要一分钟!
Is this normal? 这是正常的吗? How do I find out what's slowing casper/phantom down?
我如何找出减慢casper / phantom的速度? I am suspecting its some HTTP redirects that casper is not following?
我怀疑它的一些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();
Are you on Windows? 你在Windows上吗? If yes, there is a mysterious network problem when automatic proxy is being used.
如果是,则在使用自动代理时会出现神秘的网络问题。 See the release notes for more details: http://phantomjs.org/release-1.9.html .
有关更多详细信息,请参阅发行说明: http : //phantomjs.org/release-1.9.html 。
In general, try to analyze the network requests and responses. 通常,尝试分析网络请求和响应。 A very simple way to trace the network traffic:
跟踪网络流量的一种非常简单的方法:
page.onResourceRequested = function (request) {
console.log('Request ' + JSON.stringify(request, undefined, 4));
};
page.onResourceReceived = function (response) {
console.log('Receive ' + JSON.stringify(response, undefined, 4));
};
You need to tweak it further if you want the timing etc. Read the documentation on this Network Monitoring features. 如果您需要时序等,则需要进一步调整它。阅读有关此网络监视功能的文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.