Last active
October 13, 2015 16:51
-
-
Save ibnesayeed/454b249e4c3e87ce550a to your computer and use it in GitHub Desktop.
Screen Capture Using PhantomJS
This file contains hidden or 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 gutenberg = ['gutenberg-pride-and-prejudice']; | |
| var count = 0; | |
| var fns = gutenberg; | |
| var dom = 'gutenberg'; | |
| function capturePage(url, opf, idx) { | |
| var page = require('webpage').create(); | |
| page.settings.userAgent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.70 Safari/537.17'; | |
| page.viewportSize = { | |
| width: 1024, | |
| height: 768 | |
| }; | |
| page.clipRect = { | |
| top: 0, | |
| left: 0, | |
| width: 1024, | |
| height: 768 | |
| }; | |
| page.open(url, function(status) { | |
| if (status !== 'success') { | |
| console.log('Unable to load #' + idx + ': ' + url); | |
| } else { | |
| console.log('Loading #' + idx + ': ' + url); | |
| setTimeout(function() { | |
| console.log('Saving #' + idx + ': ' + opf); | |
| page.render(opf); | |
| count++; | |
| if (count == fns.length) { | |
| console.log('All Done!'); | |
| phantom.exit(); | |
| }; | |
| }, 200000); | |
| } | |
| }); | |
| } | |
| for (var i = 0; i < fns.length; i++) { | |
| var url = 'http://' + dom + '.cs.odu.edu/' + fns[i] + '.html'; | |
| var opf = dom + '/' + fns[i] + '.png'; | |
| capturePage(url, opf, i); | |
| console.log('Queued #' + i + ': ' + url); | |
| }; | |
| console.log('All Queued!'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment