I am trying to take a crack at writing my first web scraper tool in Node.js since Python always gives me trouble on my Windows 11 machine. Yet, on Kali Linux 2021.3, it works flawlessly. I even have Python in my C:\ProgramFiles\Python310\python.exe, but it seems pip is still in app data. It's frustrating.
Anyway, I am trying to use the Cheerio node.js module. Still, I wanted to make sure I was even doing this correctly. I want to try and give trends.vc a try, or maybe Google search results if that page is too limited. I used ZAP in Kali to get all the URLs on trends.vc, but I am unsure if I can use them all together in one function or not.
I am experimenting with web scrapers, seeing if I can collect a list of emails from join.trends.vc or just the Google Search result method.
Below is my code for the javascript after creating a package.json and using npm test as my test command, which yields nothing as I am sure I messed this up a while ago. I also tried implementing request-promise and html-email-scraper, and others, but I know I am writing this wrong. If anyone can point me in the right direction, that would be well appreciated.
At this point in time, I am just attempting to scrape the emails from this one page and convert it into a CSV. I followed some tutorials and managed to get those working, but not for the pages I am trying to scrape.
const request = require("request-promise")
const cheerio = require("cheerio");
const fs = require('fs');
const writeStream = fs.createWriteStream('post.csv');
request("https://join.trends.vc/", (error, response, html) => {
if (!error && response.statusCode == 200) {
const $ = cheerio.load(html);
const datarow = $(".form01");
const output = datarow.find("div").text();
$(".field").each((i, data) => {
const item = $(data).text();
const item1 = $(data).text();
// Write Row To CSV
writeStream.write(`${title}, ${link}, ${date} \n`);
});
// console.log(item);
console.log(item, item1);
}
});