编辑:我正在尝试下载.csv文件。为什么这个脚本会产生一个空的EURUSD.csv
(0KB)?该链接向q.php
发送GET请求并返回.csv文件。
var casper = require('casper').create();
var x = require('casper').selectXPath;
casper.userAgent("Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0")
casper.start('http://www.thebonnotgang.com/quotes/q.php?timeframe=1m&dayFrom=2011-07-01&dayTo=&symbol=EURUSD');
casper.then(function () {
this.wait(30000);
});
casper.on('resource.received', function (resource) {
console.log(resource.url);
console.log(resource.stage);
if (resource.stage !== "end") {
console.log("resource.stage !== 'end'");
return;
}
if (resource.url.indexOf('EURUSD') > 1) {
console.log("Downloading csv file");
this.download(resource.url, 'EURUSD_1m.csv');
}
});
casper.run();
resource.stage == end
启动下载命令但它只生成一个空文件。