2021-11-29

Web scraping with cheerio not working with some elements

I just started learning about web scraping and I found this tutorial: https://www.mundojs.com.br/2020/05/25/criando-um-web-scraper-com-nodejs/

It works fine, however I'm trying to get different elements from the same webpage: https://ge.globo.com/futebol/brasileirao-serie-a/

With the group of classes of the tutorial it brings all the elements with the selected class, but with other classes it doesn't work:

enter image description here

As can be seen all fifty elements with the class ranking-item-wrapper are returned, but if I select elements with the class lista-jogos__jogo it doesn't return anything:

enter image description here enter image description here

I don't get why I'm getting this error, since I'm doing exectly the same thing as it is done in the tutorial.

Here is a short version of the code:

const axios = require('axios');
const cheerio = require('cheerio');
const url = 'https://ge.globo.com/futebol/brasileirao-serie-a/';

axios(url).then(response => {
  const html = response.data;
  const $ = cheerio.load(html);
  console.log($('.ranking-item-wrapper')) // => tutorial class
  console.log('***')
  console.log($('.lista-jogos__jogo')) // => class that I'm using
}).catch(console.error);


from Recent Questions - Stack Overflow https://ift.tt/313QmWS
https://ift.tt/3D0Fupx

No comments:

Post a Comment