After running this code he save an infinite number of files with the source code of the first page("http://site1.com"), why he doesn't go through other links and doesn't stop ?
var args = ["http://site1.com", "http://site2.com", "http://site3.com"];
var fs = require('fs');
var i = 0;
function handle_page(file){
page.open(file,function(){
page.evaluate(function(){
fs.write(i + '.html', page.content, 'w');
});
setTimeout(next_page,100);
});
}
function next_page(){
var file = args.shift();
if(!file){ phantom.exit(0); }
i++
handle_page(file);
}
next_page();