Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Node web scraper with axios and cheerio

Node JS Web Scraper

I this is part of the first node web scraper I created with axios and cheerio. I took out all of the logic, since I only wanted to showcase how a basic setup for a nodejs web scraper would look.

const cheerio = require('cheerio'),
      axios = require('axios'),
      url = `<url goes here>`;
      
axios.get(url)
    .then((response) => {
        let $ = cheerio.load(response.data);
        $('a').each(function (i, e) {
          let links = $(e).attr('href');      
          console.log(links);
      })
    }).catch(function (e) {
    console.log(e);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.