Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@reidransom
Last active August 13, 2016 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reidransom/2ff0be88e0f4fa902877ba56b58f7a93 to your computer and use it in GitHub Desktop.
Save reidransom/2ff0be88e0f4fa902877ba56b58f7a93 to your computer and use it in GitHub Desktop.
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() {
casper.evaluate(function () {
;['swoosh', 'bricks'].forEach(function (clsname) {
var els = document.getElementsByClassName(clsname)
for (var i=0; i<els.length; i++) {
els[i].style.opacity = '1'
}
})
})
var fs = require('fs');
fs.write('asd.html', this.getHTML(), 'wb');
this.capture(filename);
});
});
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment