Created
April 18, 2013 20:30
-
-
Save verdi327/5415969 to your computer and use it in GitHub Desktop.
news_screenshot
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
function newspaper(name, left, top, width, height) { | |
this.name = name; | |
this.left = left; | |
this.top = top; | |
this.width = width; | |
this.height = height; | |
} | |
var nyTimes = new newspaper('nytimes', 200, 440, 1400, 800); | |
var laTimes = new newspaper('latimes', 500, 200, 1000, 900); | |
var bbc = new newspaper('bbc', 500, 500, 400, 600); | |
var newspapers = [nyTimes, laTimes, bbc]; | |
for (var i=0; i < newspapers.length; i++ ) { | |
var url = 'http://' + newspapers[i].name + '.com' | |
var page = require('webpage').create(); | |
page.open(url, function (status) { | |
if (status !== 'success') { | |
console.log('Unable to load' + url + '!'); | |
phantom.exit(); | |
} else { | |
window.setTimeout(function () { | |
page.zoomFactor = 2 | |
console.log("visiting" + '-' + url) | |
page.clipRect = { left: newspapers[i].left, | |
top: newspapers[i].top, | |
width: newspapers[i].width, | |
height: newspapers[i].height }; | |
page.render(newspapers[i].name + '_homepage' + timestamp() + '.png'); | |
phantom.exit(); | |
}, 2000); | |
} | |
}); | |
} | |
function timestamp(){ | |
var today_date = new Date() | |
var year = today_date.getFullYear() | |
var month = today_date.getMonth() + 1 | |
var day = today_date.getDate() | |
return '_' + month + '_' + day + "_" + year | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment