Cheerio: Selecting "content" of "meta" tag

Created on 16 Sep 2017  ·  1Comment  ·  Source: cheeriojs/cheerio

My Code is okey with This:

request('https://example.com', function (error, response, html) {
  if (!error && response.statusCode == 200) {
    const $ = cheerio.load(html);
      console.log(html);
  }
});

I need to get 사이드 from content:

<meta property="og:description" content="👤 I'm Jack">
<meta property="og:title" content="사이드">  // How to Get `사이드` and print in console.log?

Most helpful comment

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
  }
});

>All comments

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
  }
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

miguelmota picture miguelmota  ·  3Comments

M3kH picture M3kH  ·  4Comments

AlbertoElias picture AlbertoElias  ·  4Comments

trevorfrese picture trevorfrese  ·  4Comments

francoisromain picture francoisromain  ·  5Comments