Answers for "cheerio library to parse the meta tags in url"

0

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
  }
});
Posted by: Guest on October-30-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language