I have written a Puppeteer script that scrapes text from a website (it's a GUI that displays the server's log files -- it's a Squarespace site, so that's the only way I can access the log files).
This is how the lines appear in the GUI:
The script reads this (and every row below it) and outputs it to a the console.log() currently.
That record above outputs like this:
11/9/2018 at 12:21:44pm70.119.157.106AboutHostname:70.119.157.106Location:Carrollton, Texas, United StatesTags:-Referrer:www.website.com/Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
And they get placed end-to-end in the output in a giant block like this:
11/9/2018 at 12:21:44pm70.119.157.106AboutHostname:70.119.157.106Location:Carrollton, Texas, United StatesTags:-Referrer:www.website.com/Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.3611/9/2018 at 12:21:33pm70.119.157.106HomesitesHostname:70.119.157.106Location:Carrollton, Texas, United StatesTags:-Referrer:www.website.com/about/Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.3611/9/2018 at 12:21:26pm70.119.157.106AboutHostname:70.119.157.106Location:Carrollton, Texas, United StatesTags:-Referrer:www.website.com/Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.3611/9/2018 at 12:21:15pm70.119.157.106HomeHostname:70.119.157.106Location:Carrollton, Texas, United StatesTags:-Referrer:-Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
I am now at the step where I'm trying to figure out how to write this to CSV instead of to terminal with console.log(textContent);
.
What is the best way to write this to a CSV?
(The following step will be parsing all this, but...baby steps...)