php - CasperJS/PhantomJS 比 Curl 慢得多

标签 php web-scraping screen-scraping phantomjs casperjs

当我尝试 curl www.yelp.com 时,它需要 1.1 秒。然而,使用 CasperJS 检索页面需要超过一分钟的时间!

这正常吗?我如何找出是什么在减慢 casper/phantom 的速度?我怀疑 casper 没有遵循它的某些 HTTP 重定向?

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();

enter image description here

最佳答案

你在 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));
};

如果您需要时间等,您需要进一步调整它。阅读有关此 Network Monitoring 的文档特征。

关于php - CasperJS/PhantomJS 比 Curl 慢得多,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15859454/

相关文章:

PHP MySql Query get 使用 dateencode 在 'October-01-2015' 和 'December-31-2015' 之间获取所有信息

PHP 和 SQL 问题

java - HTML 解析/抓取算法帮助..Java

python - 如何在不使用 Selenium 的情况下抓取 WHO 流感数据?

python - 将蜘蛛结果保存到数据库

python - 使用 Python 下载 URL 的 html - 但启用了 javascript

scala - 是否有 Python 的 Mechanize 的 Scala 版本?

php - mysqli_query() 期望参数 2 为字符串

javascript - 通过 JS 使用 php 检测用户是否已注销(没有 session ),如果是,则停止执行 JS 函数的其余部分

app-store - 获取应用商店数据