Skip to content

Instantly share code, notes, and snippets.

@carboleda
Last active April 11, 2020 20:19
Show Gist options
  • Save carboleda/33a3a7fcf5a557bf2f72b95ce4680e50 to your computer and use it in GitHub Desktop.
Save carboleda/33a3a7fcf5a557bf2f72b95ce4680e50 to your computer and use it in GitHub Desktop.
NodeJS scraping
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