Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example CKAN instance screenshot taker
var webshot = require('webshot');
var gm = require('gm');
var options = {
screenSize: {
width: 1015, height: 725
},
renderDelay: 500
};
var sites = [
"http://google.com/"
];
for (var i in sites) {
var id = sites[i].replace('http://', '');
id = id.replace('https://', '');
id = id.replace(/\./g, '_');
if (id.substr(-1) == '/') {
id = id.substr(0, id.length-1);
}
id = id.replace('/', '_');
id = id.replace('-', '_');
console.log(id);
webshot(sites[i], 'grab/'+id+'.png', options, function(err) {
if (err) {
console.log(err);
} else {
console.log('Saved');
gm('grab/'+id+'.png')
.resize(350, 250)
.write('grab/'+id+'.png', function (err) {
if (err) {
console.log(err);
} else {
console.log('Resized');
}
});
}
});
}
  1. npm install webshot gm
  2. mkdir grab
  3. node screens
  4. profit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.