I like to search a list of search strings using PhantomJS and Save the results but for some reason it is not working and it only saves the last string search result page.
Below is the code.
Any input is well appreciate it.
var AddressList = [
'ODEON & UCI Cinemas Milton Keynes, United Kingdom'
,'GP Bullhound London, United Kingdom'
// ,'G4S London, United Kingdom'
// ,'Lloyds Banking Group London, United Kingdom'
];
var i = 0;
function pausecomp(millis)
{
var date = new Date();
var curDate = null;
do { curDate = new Date(); }
while(curDate-date < millis);
}
for (i = 0; i < AddressList.length; i++)
{
var page = require('webpage').create();// new WebPage()
var fs = require('fs');
// page.onLoadFinished = function() {
// console.log("page " + i + " load finished");
// page.render('export.png');
// fs.write('File_'+(new Date()).getTime()+'.html', page.content, 'w');
// phantom.exit();
// };
page.index = i + "_";
page.onLoadFinished = function() {
console.log("page " + this.index + " load finished");
page.render('export.png');
fs.write('File_'+(new Date()).getTime()+'.html', page.content, 'w');
};
function()
{
page.evaluate(function() { });
});
// pausecomp(10000);
}
// phantom.exit();