initial commit
This commit is contained in:
42
tissparse.js
Normal file
42
tissparse.js
Normal 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}
|
||||
Reference in New Issue
Block a user