Skip to content

Instantly share code, notes, and snippets.

@comodoro
Created July 21, 2018 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save comodoro/3b0534f4e821e9055f3cb78fa4e5513b to your computer and use it in GitHub Desktop.
Save comodoro/3b0534f4e821e9055f3cb78fa4e5513b to your computer and use it in GitHub Desktop.
Scrape with node and cheerio
const rp = require('request-promise');
const cheerio = require('cheerio');
const options = {
uri: `http://www.chess.cz/soutez/vysledky/2017/kolo-1/`,
transform: function (body) {
return cheerio.load(body, {normalizeWhitespace: true});
}
};
rp(options)
.then(($) => {
$('.table-responsive').children('table').each(function (i, element) {
console.log(i);
console.log($(element).text().trim());
});
})
.catch((err) => {
console.log(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment