Skip to content

Instantly share code, notes, and snippets.

@mjgil-gist
Created June 18, 2013 18:42
Show Gist options
  • Save mjgil-gist/5808097 to your computer and use it in GitHub Desktop.
Save mjgil-gist/5808097 to your computer and use it in GitHub Desktop.
function renderPage(url) {
var page = require('webpage').create();
var redirectURL = null;
page.onResourceReceived = function(resource) {
if (url == resource.url && resource.redirectURL) {
redirectURL = resource.redirectURL;
}
};
page.open(url, function(status) {
if (redirectURL) {
renderPage(redirectURL);
} else if (status == 'success') {
// ...
} else {
// ...
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment