We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const request = require("request-promise") const cheerio = require("cheerio") const fs = require("fs") const json2csv = require("json2csv").Parser;
const coronaURL = "https://www.worldometers.info/coronavirus/country/india/";
(async() => { const coronaData = [] const response = await request({ uri: coronaURL, headers: { accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9", "accept-encoding": "gzip, deflate, br", "accept-language": "en-US,en-IN;q=0.9,en;q=0.8,kn;q=0.7", }, gzip: true, });
let $ = cheerio.load(response) let totalCases = $('div[class="maincounter-number"] > span[style="color:#aaa"]').text().trim(); //let totalCases = $('div[class="title_wrapper"]> h1').text().trim(); console.log(totalCases); coronaData.push({ totalCases }); console.log(coronaData); const json2csvParser = new json2csv(); const csv = json2csvParser.parse(coronaData); fs.writeFileSync("./coronaCount.csv", csv, "utf-8")
}
)();
This is the node.js code. I'm new to web-scrapping and node.js. It returns an empty string. Can anyone please help me?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
const request = require("request-promise")
const cheerio = require("cheerio")
const fs = require("fs")
const json2csv = require("json2csv").Parser;
const coronaURL = "https://www.worldometers.info/coronavirus/country/india/";
(async() => {
const coronaData = []
const response = await request({
uri: coronaURL,
headers: {
accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9",
"accept-encoding": "gzip, deflate, br",
"accept-language": "en-US,en-IN;q=0.9,en;q=0.8,kn;q=0.7",
},
gzip: true,
});
}
)();
This is the node.js code.
I'm new to web-scrapping and node.js.
It returns an empty string. Can anyone please help me?
The text was updated successfully, but these errors were encountered: