I'm beginner with cheerio, trying to implement a simple example to learn more about it. tried some solutions on Stackoverflow without success, for the beginning tried it on google website, just for my learn, marked the element I want with yellow, help some1 please?
my code:
const cheerio = require('cheerio');
const request = require('request');
request({
method: 'GET',
url: 'https://www.google.co.il/'
}, (err, res, body) => {
if (err) return console.error(err);
let $ = cheerio.load(body);
$('div[class="gb_h gb_i"]').find('a').each(function (index, element) {
console.log(element.attr(href));
});
});
the elements in google: