4

Try to get names of mathes in "Starting soon" section of this web-site: 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 blank array. I'm not quite understand how the deep nesting works in this case.

ggorlen
  • 44,755
  • 7
  • 76
  • 106
n00b43677
  • 187
  • 2
  • 16
  • 2
    The "startsoon" table is created dynamically by a script `startingsoon.js` which first loads JSON data from the server. You'll need to use a scrapping engine which can execute scripts on the page and wait for the results – xmojmr Dec 07 '14 at 13:53
  • 1
    Maybe this is the json that you are looking for - https://favbet.com/bets/starting_soon/. No need screen scrapping. :) – hutingung Dec 09 '14 at 08:16
  • haha, thank you) How you find it? – n00b43677 Dec 09 '14 at 09:04
  • 1
    Please be careful when using this in consideration to usage rights. You are probably not allowed to show case data from this json on your web page. – subZero Dec 09 '14 at 09:04
  • ok, I will read terms and conditions before use it in my code – n00b43677 Dec 09 '14 at 09:06

0 Answers0