Created
July 21, 2018 07:43
-
-
Save comodoro/3b0534f4e821e9055f3cb78fa4e5513b to your computer and use it in GitHub Desktop.
Scrape with node and cheerio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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