My node app get HTML code from a certain webiste with request library. And by using jQuery (cheerio) I want to find a href to contact section. But then I get only undefined value.
request(options.websiteUrl, (err, response, body) =>{
if(!err && response.statusCode == 200){
let $ = cheerio.load(body);
let contact = $('a:contains("contact")').attr('href');
console.log(contact); //undefined
}
});
I've pasted the same jQuery command directly into that website's JS console and it works fine, giving me proper href. What's the difference between regular jQuery and Cheerio that makes me unable to execute that code inside my node app and how can I fix it?