My goal is open many pages(with a short delay) and save my data to a file.
But my code does not work.
var gamesList = [url1,url2,url3];
//gamesList i
Explanation above is very helpful to me. So, thanx a lot. Come to the point, sometimes js function renders even after the page has already loaded, in this scenario setTimeout() method, is very helpful. And,I faced problem like this when scraping many site....I used setTimeout() method in this way,
`
function handle_page(url){page.open(url, function() {setTimeout(function() {var html_text=page.evaluate(function(){
var is= document.querySelectorAll("li.bookinDetails_c1_180616")[0].textContent;
var isbn=is.trim();
//return s1;
var w,x,y,z,z1,w1,u,a;
a= document.querySelectorAll("li.selectableBook");
if(a.length==5){
w1=document.querySelectorAll("span.bookPrice")[0].textContent;
w=w1.trim();
x1=document.querySelectorAll("span.bookPrice")[1].textContent;
x=x1.trim();
y1=document.querySelectorAll("span.bookPrice")[2].textContent;
y=y1.trim();
z1=document.querySelectorAll("span.bookPrice")[3].textContent;
z=z1.trim();
u=isbn+"=>["+"RENT USED:-"+w+","+"RENT NEW:-"+x+","+"BUY USED:-"+y+","+"BUY NEW:-"+z+"]";
return u;
}else{
y1=document.querySelectorAll("span.bookPrice")[0].textContent;
y=y1.trim();
z1=document.querySelectorAll("span.bookPrice")[1].textContent;
z=z1.trim();
u=isbn+"=>["+"BUY USED:-"+y+","+"BUY NEW:-"+z+"]";
return u;
}
});
fs.write('html.txt',html_text+'\r\n','a');
next_page();
}, 400);
});
}
`