0

I'm trying to run a simple cheerio scraping script here:

      var $ = cheerio.load(body);
      var scoresTable = $('.grey').html();
      var scoresTableTbody = scoresTable('tbody');
      console.log(scoresTableTbody);

But the return is:

scoresTable is not a function

I also tried changing var scoresTable = $('.grey').html(); into var scoresTable = $('.grey');, but same error.

Appreciate any help :)

MarcoL
  • 9,829
  • 3
  • 37
  • 50
jwitos
  • 492
  • 3
  • 7
  • 24

1 Answers1

3

scoresTable is an string, not a function.

Assuming grey is a class assigned to a table try, to get the object reference to that element then use .find() get the tbody like

var $ = cheerio.load(body);
var scoresTable = $('.grey');
var scoresTableTbody = scoresTable.find('tbody');
console.log(scoresTableTbody);
Arun P Johny
  • 384,651
  • 66
  • 527
  • 531