3
var casper = require('casper').create({
viewportSize: {
width: 1920,
height: 1080
},
verbose: true,
logLevel: 'debug'
});
var utils = require('utils');
casper.options.onResourceRequested = function(C, requestData, request) {
utils.dump(requestData.headers);
};
var url = casper.cli.get('url');
var filename = casper.cli.get('filename');
var headers = casper.cli.get('storefront');
if (headers != null) {
casper.userAgent('iTunes/12.4.3 (Windows; Microsoft Windows 10.0 x64 Business Edition (Build 9200); x64) AppleWebKit/7601.6016.1000.7');
}
casper.start().then(function() {
casper.page.customHeaders = {
'X-Apple-Store-Front': headers,
'X-Apple-Tz': '3600'
};
casper.thenOpen(url, function() {
this.wait(2000, function() {
var fs = require('fs');
fs.write('asd.html', this.getHTML(), 'wb');
this.capture(filename);
});
});
});
casper.run();
casperjs screenshot.js --storefront="143441-1,12 ab:SwTTXLh0" --url="https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewGrouping?cc=us&id=37" --filename=tv.jpg
CasperJS not loading javascripts?
当试图转储这个页面,这不是给我完全的JavaScript旋转木马或任何东西。我真的不知道什么原因导致加载失败,并想知道是否有人有任何其他经验呢?
PhantonJS版本是2.1.1。 CasperJS版本是1.1.1。
您使用哪个PhantomJS版本?请注册到'resource.error','page.error','remote.message'和'casper.page.onResourceTimeout'事件([Example](https://gist.github.com/artjomb/4cf43d16ce50d8674fdf#file -2_caspererrors-JS))。也许有错误。 –
更新了帖子。 'Error:ITSExceptionHandler:ITSExceptionHandler:{message:“ReferenceError:Can not find variable:iTunes”,url:“https://itunes.apple.com/htmlResources/CBCB/dt-storefront-base.js”, lineNumber:“1023”}' '错误:ReferenceError:无法找到变量:iTunes' casperjs版本是1.1.1 –
PhantomJS也是2.1.1。 –