Last active
August 29, 2015 14:16
-
-
Save zxqx/5f565645755701cc70ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var curl = require('curlrequest'); | |
var cheerio = require('cheerio'); | |
var htmlToJson = require('html-to-json'); | |
var SCHEDULE_URL = 'http://www.teamsideline.com/Org/StandingsResults.aspx?d=xRIu3qqX6IiJhYMtStQM19yg%2bGldWQ%2fwY6l1Ih06EiU%2fAloRbrErPgMTYoSrfOkeDoJnrrWK7go%3d'; | |
curl.request({ url: SCHEDULE_URL }, function(err, res) { | |
$ = cheerio.load(res); | |
var schedule = $('#ctl00_OrgContentUnit_ScheduleGrid_ctl00 tbody').html(); | |
htmlToJson.parse(schedule, ['tr:not(.rgGroupHeader) td', function($schedule) { | |
return $schedule.text().trim(); | |
}]) | |
.done(function(items) { | |
var games = []; | |
var timesToSplice = items.length / 5; | |
for (var i=0; i < timesToSplice; i++) { | |
games.push(items.splice(0, 5)); | |
} | |
var gamesFormatted = []; | |
games.forEach(function(g) { | |
var game = {}; | |
game.date = g[0]; | |
game.time = g[1]; | |
game.away = g[2]; | |
game.home = g[3]; | |
game.location = g[4]; | |
gamesFormatted.push(game); | |
}); | |
console.log(gamesFormatted); | |
console.log(gamesFormatted.length); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment