Scraper with Node.js and Cheerio

Try to get the names of the mates in the "Starting Soon" section of this website: https://favbet.com/en/bets/

This is my code:

var request = require('request'),
        cheerio = require('cheerio');
        matches = [];

    request('https://favbet.com/en/bets/', function(err, resp, body){
        if (!err && resp.statusCode == 200) {
            var $ = cheerio.load(body);
            var content = $('#startsoon').find('li.col20').each(function() {
                var match = this.text();
                matches.push(match);
            });
            console.log(matches);
        }
    });

      

Console.log returns an empty array. I don't quite understand how deep nesting works in this case.

+3


source to share





All Articles