Skip to content

Instantly share code, notes, and snippets.

@sanusart
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save sanusart/25518a6e093ed4ba0148 to your computer and use it in GitHub Desktop.

Select an option

Save sanusart/25518a6e093ed4ba0148 to your computer and use it in GitHub Desktop.
Take screenshots of web sites #phantomjs #screenshot

Install phantomJs

Run:

[sudo] npm install --global phantomjs

Start

Run:

./phantomjs screen.js
/* jshint undef: true, unused: true, curly: true, forin: true, node: true, phantom: true, noempty: true */
'use strict';
var sites = [
'http://gistoapp.com',
'http://www.sanusart.com',
'http://atom.io'
];
sites.forEach(function(site, index) {
index++;
console.log('Site ' + index + ' out of ' + sites.length);
var page = require('webpage').create();
console.log('Site: ', site);
page.settings.userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36';
page.viewportSize = {
width: 1366,
height: 768
};
page.clipRect = {
top: 0,
left: 0,
width: 1366,
height: 768
};
page.open(site, function() {
page.render(site.split('//')[1] + '.png');
if (index === sites.length) {
phantom.exit();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment