cheerio get plain code example
Example 1: cheerio example
const cheerio = require('cheerio');
let $ = cheerio.load(<body>);
let title = $('title');
console.log(title.text());
Example 2: cheerio library to parse the meta tags in url
request('https://example.com', function (error, response, html) {
if (!error && response.statusCode == 200) {
const $ = cheerio.load(html);
console.log($("meta[property='og:title']").attr("content"));
//or
console.log($("meta").get(1).attr("content")); // index of the meta tag
}
});