Last active
December 16, 2015 12:28
-
-
Save ahomu/5434465 to your computer and use it in GitHub Desktop.
スクリーンショットをガンガン撮るぞくん require phantomjs >1.7, async.js >0.2.7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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