Skip to content

Instantly share code, notes, and snippets.

@iwek
Created October 21, 2012 19:00
Show Gist options
  • Save iwek/3928097 to your computer and use it in GitHub Desktop.
Save iwek/3928097 to your computer and use it in GitHub Desktop.
grab html source in casperjs or phantomjs
//phantomjs
var page = require('webpage').create();
var url = 'http://instagram.com/';
page.open(url, function (status) {
var js = page.evaluate(function () {
return document;
});
console.log(js.all[0].outerHTML);
phantom.exit();
});
//casperjs
var casper = require('casper').create();
var url = 'http://instagram.com/';
casper.start(url, function() {
var js = this.evaluate(function() {
return document;
});
this.echo(js.all[0].outerHTML);
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment