From a4bb6c59e44df6b0d6271acf21a0d2d012941e1c Mon Sep 17 00:00:00 2001 From: Bram van der Veen <96aa48@gmail.com> Date: Sun, 21 Jun 2015 00:21:25 +0200 Subject: [PATCH] Added a function for parsing schedule_types --- schedule.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/schedule.js b/schedule.js index cacbc5f..69e8e23 100644 --- a/schedule.js +++ b/schedule.js @@ -26,9 +26,21 @@ function get(url, callback) { }); } +function schedule_types(page) { + var extract = cheerio('table tr td[valign="bottom"] table tr td b, table tr td[valign="bottom"] table tr td a', page).text().split(/\s\s/); + var types = []; + + for (element of extract) { + element != '' ? types.push(element) : null; + } + + return types +} + //Function for converting the page into a json dataset. function to_json(page) { var result = cheerio('td:nth-child(3) table', page); + var types = schedule_types(page); var is_teacher = cheerio(cheerio(page).find('tr.CoreDark').find('td')[3]).find('a').html() == null; var amount_of_days = cheerio(result).find('tr.AccentDark').find('td').length - 1; var amount_of_hours = config().amount_of_hours;