Getting Start With Cheerio
function parseHtml(html) {
// Load the html in cheerio
const $ = cheerio.load(html);
// Load the reviews
const reviews = $('.review');
reviews.each((i, review) => {
// Find the text children
const textReview = $(review).find('.review-text').text();
console.log(textReview);
})
}
request('https://www.amazon.com/dp/B077JP5B5X', function (error, response, body) {
console.log('error:', error);
// Print the error if one occurred
console.log('statusCode:', response && response.statusCode);
// Print the response status code if a response was received
console.log('body:', body);
// Print the HTML for the Google homepage.
parseHtml(body);
});
Runkit Sample
var getJSON = require("async-get-json");
await getJSON("https://storage.googleapis.com/maps-devrel/google.json");