Last active
April 11, 2020 20:19
-
-
Save carboleda/33a3a7fcf5a557bf2f72b95ce4680e50 to your computer and use it in GitHub Desktop.
NodeJS scraping
This file contains hidden or 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 axios = require('axios'); | |
const cheerio = require('cheerio'); | |
async function cheerioExample() { | |
const pageContent = await axios.get('https://slides.com/carboleda'); | |
const $ = cheerio.load(pageContent.data); | |
const presentations = $('li.deck.public').map((_, el) => { | |
el = $(el); | |
const title = el.find('span.deck-title-value').text(); | |
const description = el.find('span.deck-description-value').text(); | |
const link = el.find('a.deck-link').attr('href'); | |
return { title, description, link }; | |
}).get(); | |
console.log(presentations); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment