Skip to content

Instantly share code, notes, and snippets.

@Yash-567
Forked from andrewjmead/scrape-reddit.js
Created July 14, 2019 02:51
Show Gist options
  • Save Yash-567/63fdcdcfb621957fac79bd57ac2a78c8 to your computer and use it in GitHub Desktop.
Save Yash-567/63fdcdcfb621957fac79bd57ac2a78c8 to your computer and use it in GitHub Desktop.
Request & Cheerio Scraping Example
var request = require('request');
var cheerio = require('cheerio');
request('https://www.reddit.com/', function (error, response, body) {
$ = cheerio.load(body);
$('a.title').each(function (i, elem) {
console.log('');
console.log('** Link ** ')
console.log($(this).text());
console.log($(this).attr('href'));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment