initial commit

This commit is contained in:
www
2020-08-18 05:07:50 +00:00
commit 73e594cf77
6 changed files with 649 additions and 0 deletions

42
tissparse.js Normal file
View File

@@ -0,0 +1,42 @@
const cheerio = require('cheerio');
function courselist(html) {
$ = cheerio.load(html);
tab=[];
studium="";
pruefungsfach="";
$('table').find('tr').each((index,element)=>{
let element_first=$(element).find('td.nodeTable-title > div.ui-widget');
if (element_first.hasClass("nodeTable-level-0")) {
studium=element_first.text().replace(/^[\s\n]+|[\s\n]+$/g, '')
}
if (element_first.hasClass("nodeTable-level-1")) {
pruefungsfach=element_first.text().replace(/^[\s\n]+|[\s\n]+$/g, '')
}
if (element_first.hasClass("nodeTable-level-2")) {
modul=element_first.text().replace(/^[\s\n]+|[\s\n]+$/g, '')
}
if (element_first.hasClass("nodeTable-level-4")) {
let course_key=element_first.find("div.courseKey").text();
course_key=course_key.replace(/^[\s\n]+|[\s\n]+$/g, '');
let ects=$(($(element).find("td.nodeTable-short")).toArray()[2]).text()
let std=$(($(element).find("td.nodeTable-short")).toArray()[1]).text()
tab.push({"href": element_first.find("a").attr("href"),
"studium": studium,
"pruefungsfach": pruefungsfach,
"modul":modul,
"ects":ects,
"std":std,
"courseKey": course_key,
"lvanr": course_key.split(" ")[0],
"lvatyp": course_key.split(" ")[1],
"lvasem": course_key.split(" ")[2],
"courseTitle":element_first.find("div.courseTitle").text().replace(/^[\s\n]+|[\s\n]+$/g, '')
})
}
})
return tab;
}
module.exports = {courselist}