Last active
December 29, 2015 23:59
-
-
Save komljen/7746529 to your computer and use it in GitHub Desktop.
This script will load whole webpage and return processed html. Also it will skip Google Analytics (ga.js). Usage: phantomjs get.js http://www.example.com More info here: http://www.techbar.me/performance-testing-with-phantomjs/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var page = require('webpage').create(), | |
system = require('system'), | |
address; | |
address = system.args[1]; | |
page.onResourceRequested = function (requestData, request) { | |
if ((/ga.js/gi).test(requestData['url'])) { | |
console.log('Skiping: ' + requestData['url']); | |
request.abort(); | |
} | |
}; | |
page.open(address, function (status) { | |
if (status !== 'success') { | |
console.log('Unable to access network'); | |
} else { | |
var p = page.evaluate(function () { | |
return document.getElementsByTagName('html')[0].innerHTML | |
}); | |
console.log(p); | |
} | |
phantom.exit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment