Created
October 7, 2019 17:37
-
-
Save nkhil/9e720b1f6310a9b0fe29d900f9e90328 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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