Skip to content

Instantly share code, notes, and snippets.

@nkhil
Created October 7, 2019 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nkhil/9e720b1f6310a9b0fe29d900f9e90328 to your computer and use it in GitHub Desktop.
Save nkhil/9e720b1f6310a9b0fe29d900f9e90328 to your computer and use it in GitHub Desktop.
const fetch = require('node-fetch');
const cheerio = require('cheerio');
async function get() {
const data = await fetch('https://httpstatuses.com/200').then(res => res.text())
console.log('\n =========================>: get -> data', data);
const $ = cheerio.load(data);
const fullTitle = $('title').text();
console.log('\n =========================>: get -> title', fullTitle);
const title = fullTitle.split('—')[0];
console.log('\n =========================>: get ->', title);
const description = $('meta').second();
console.log('\n =========================>: get -> description', description);
}
get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment