Skip to content

Instantly share code, notes, and snippets.

@jeremyfelt
Created December 3, 2012 20:38
Show Gist options
  • Save jeremyfelt/4197835 to your computer and use it in GitHub Desktop.
Save jeremyfelt/4197835 to your computer and use it in GitHub Desktop.
Phantom JS Test
all_data = {
current_url : '',
current_domain : '',
page : false,
domains : [
{'url':'google.com'},
{'url':'wordpress.org'},
{'url':'wordpress.com'},
{'url':'10up.com'}
]
};
all_data.process = function () {
if (0 === all_data.domains.length) {
phantom.exit();
} else {
all_data.current_url = all_data.domains.pop();
all_data.current_domain = 'http://' + all_data.current_url.url;
all_data.page = require('webpage').create();
all_data.page.settings.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1309.0 Safari/537.17';
all_data.page.viewportSize = { width: 1368, height: 800 };
all_data.page.open( all_data.current_domain, all_data.on_open);
}
};
all_data.on_open = function(status) {
if ( 'success' === status) {
console.log( 'success ' + all_data.current_url.url );
all_data.page.render(all_data.current_url.url + '.png');
} else {
console.log( 'fail ' + all_data.current_url.url );
}
all_data.page.release();
all_data.process();
};
all_data.process();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment