DEV Community

Discussion on: How to scrape that web page with Node.js and puppeteer

Collapse
 
usbinternet profile image
USB-internet

Hi,
Francesco Napoletano,
Your code is great !!!

But, I can not save data to a .txt file. It reports an Undefined error. Help me fix it. Why use:

for(var i = 0; i < result.length; i++) {
console.log('Post: ' + result[i].title + ' URL: ' + result[i].url);

}

I can not export the value, it just seems to print to the screen
If exported to .txt file, it appears Undefined error. Please help me export the .txt file

!!! Thanks

NO ERROR BUT devnew Undefined !!!
var devnew = result.title ;

fs.writeFile('devnew.txt',devnew,'utf8');