Skip to content

Instantly share code, notes, and snippets.

@letanure
Created December 12, 2013 20:26
Show Gist options
  • Select an option

  • Save letanure/7934830 to your computer and use it in GitHub Desktop.

Select an option

Save letanure/7934830 to your computer and use it in GitHub Desktop.
ar page = require('webpage').create(),
system = require('system'),
address, output, size;
var lista = [
{ url: 'http://www.americanas.com.br/', name: 'americanas', height: 3000 },
{ url: 'http://www.ricardoeletro.com.br/', name: 'ricardoeletro', height: 3000 },
{ url: 'http://www.casasbahia.com.br/', name: 'casasbahia', height: 3000 },
{ url: 'http://www.magazineluiza.com.br/', name: 'magazineluiza', height: 9000 },
{ url: 'http://www.pontofrio.com.br/', name: 'pontofrio', height: 3000 },
{ url: 'http://www.shoptime.com.br/', name: 'shoptime', height: 3000 },
{ url: 'http://www.extra.com.br/', name: 'extra', height: 3000 },
{ url: 'http://www.submarino.com.br/', name: 'submarino', height: 3000 }
]
function print(count){
if (count >= lista.length ) {
return false;
};
var d = new Date();
var data = [d.getDate(), d.getMonth()+1, d.getFullYear(), d.getHours(), d.getMinutes()].join('-');
address = lista[count].url;
output = data + '--' + lista[count].name + '.jpg';
page.viewportSize = { width: 1600, height: lista[count].height };
console.log(address)
page.open(address, function (status) {
if (status !== 'success') {
console.log('falha no carregamento!');
// phantom.exit();
} else {
window.setTimeout(function () {
page.evaluate(function() {
window.document.body.scrollTop = document.body.scrollHeight;
});
window.setTimeout(function () {
page.render(output, { quality: 70 });
window.setTimeout(function () {
print( ++count )
}, 5000);
}, 20000);
}, 5000);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment