Added a function for parsing schedule_types
This commit is contained in:
parent
30df94a246
commit
a4bb6c59e4
12
schedule.js
12
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 for converting the page into a json dataset.
|
||||||
function to_json(page) {
|
function to_json(page) {
|
||||||
var result = cheerio('td:nth-child(3) table', 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 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_days = cheerio(result).find('tr.AccentDark').find('td').length - 1;
|
||||||
var amount_of_hours = config().amount_of_hours;
|
var amount_of_hours = config().amount_of_hours;
|
||||||
|
|
Loading…
Reference in a new issue