scrape ycombinator in javascript

index.tsx
const axios = require('axios');
const cheerio = require('cheerio');

const url = 'https://news.ycombinator.com/';

axios.get(url)
  .then(response => {
    const html = response.data;
    const $ = cheerio.load(html);

    $('.title a').each((index, element) => {
        console.log($(element).text());
    });
  })
  .catch(error => {
    console.log(error);
  });
367 chars
18 lines

related categories

gistlibby LogSnag