我使用casperjs,所以有一些例子:
casper.start('http://lacoa.org/pdf/emergencysurvivalguide-lowres.pdf', function() {
this.wait(1000, function() {
casper.capture(filepath);
});
});
我知道它是一个文件,而不是一个页面,但是我可以在浏览器中打开一个文件并进行捕获吗?感谢。
答案 0 :(得分:0)
您正在寻找casper.download
var pdfUri = 'http://lacoa.org/pdf/emergencysurvivalguide-lowres.pdf';
var casper = require('casper').create();
casper.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X)');
casper.start('http://lacoa.org', function () {
this.echo('Downloading ' + pdfUri);
this.download(pdfUri, 'download.pdf');
});
casper.run(function () {
this.echo('Done.').exit();
});
下载需要一些时间