Skip to content

Instantly share code, notes, and snippets.

@ahomu
Last active December 16, 2015 12:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ahomu/5434465 to your computer and use it in GitHub Desktop.
Save ahomu/5434465 to your computer and use it in GitHub Desktop.
スクリーンショットをガンガン撮るぞくん require phantomjs >1.7, async.js >0.2.7
var PARALLEL_LIMIT = 3;
var Page = require('webpage');
var async = require('./async.js');
var i = 0, iz;
var urls = [
"http://css.studiomohawk.com",
"http://inkdesign.jp",
"http://t32k.me/mol",
"http://havelog.ayumusato.com",
"http://aho.mu"
].map(function(url) {
return function(done) {
var page = Page.create();
page.viewportSize = {
width: 1024,
height: 768
};
i++;
console.log(i + '/' + iz + '...');
page.onLoadFinished = function() {
page.render('./shot/'+url.replace(/https?:\/\//, '').replace(/\//g, '_')+'.png');
page.close();
done(null, '✓ ' + url);
};
page.open(url);
};
});
iz = urls.length;
console.log('\ntotal ' + iz + ' urls. start page capturing…\n');
async.parallelLimit(urls, PARALLEL_LIMIT, function(err, results) {
console.log('\n' + results.join('\n'));
phantom.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment