Created
December 12, 2013 23:49
-
-
Save shaneshifflett/7937703 to your computer and use it in GitHub Desktop.
shoot old clips
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
/* | |
requires: phantomjs, async | |
usage: phantomjs index.js | |
*/ | |
var async = require('async'); | |
var sites = [ | |
['zaller', 'https://www.baycitizen.org/blogs/sandbox/digital-maps-low-cost-fighting-wildfires/'], | |
['binladen-pg-2', 'https://www.baycitizen.org/news/osama-bin-laden/san-francisco-vs-usa-rift-emerges-bin/?page=1'], | |
['binladen-pg-2', 'https://www.baycitizen.org/news/osama-bin-laden/san-francisco-vs-usa-rift-emerges-bin/?page=2'], | |
['transit-app', 'http://www.nytimes.com/2012/04/22/us/smart-muni-app-for-san-francisco-transit-goes-unused.html'], | |
['pods', 'http://gapersblock.com/mechanics/2011/02/14/study-chicagos-blue-light-cameras-why-bother/'], | |
['pods-politics', 'http://gapersblock.com/mechanics/2010/08/10/the-politics-of-watching-costbenefit-of-the-cop-in-a-box/'], | |
['zombies', 'http://www.nytimes.com/2011/10/16/us/mayoral-fund-encourages-slim-chance-candidates.html?_r=1&scp=1&sq=shane%20shifflett&st=cse'], | |
['slim-chance', 'http://www.nytimes.com/2011/08/12/us/12bcdufty.html?ref=sanfranciscobayarea&gwh=5BF6830F169D3B50C04DD2A67579D93D&_r=0'], | |
['muni-minute', 'https://www.baycitizen.org/news/transportation/muni-inflated-its-time-performance-rates/'] | |
] | |
function scrot(site, callback){ | |
var sizes = '1400x900'; | |
var siteUrl = site[1]; | |
var path = '/Users/sshifflett13/dev/shanes/shanes/base/static/articles/'; | |
var filename = path + site[0] + ".png"; | |
console.log(filename); | |
var size = sizes.split('x'); | |
var page = require('webpage').create(); | |
page.viewportSize = { width: size[0], height: size[1] }; | |
page.zoomFactor = 1; | |
// checking the viewport settings | |
console.log(siteUrl, JSON.stringify(page.viewportSize)); | |
page.open(siteUrl, function (status) { | |
page.render(filename); | |
page.close(); | |
callback.apply(); | |
}); | |
} | |
async.eachSeries(sites, scrot, function(err){ | |
if (err) console.log(err); | |
console.log('done, quitting'); | |
phantom.exit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment