From 371d09ee599a6b68760e890e9ae4f9e6aff5ed52 Mon Sep 17 00:00:00 2001 From: Mario Kahlhofer Date: Thu, 13 Jun 2024 07:37:31 +0200 Subject: [PATCH] Fix scraper because the KUSSS endpoints changed slightly --- src/app/app.ts | 2 +- src/scraper/components/courses.ts | 4 ++-- src/scraper/types.ts | 11 ++++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/app/app.ts b/src/app/app.ts index aa5a095..29ac1b3 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -91,7 +91,7 @@ export class App { xhr.onload = () => { try { if (xhr.status !== 200 && xhr.onerror) - throw new Error(xhr.status.toString()); + throw Error(xhr.status.toString()); // try parsing the response const index: IndexDto = JSON.parse(xhr.response); diff --git a/src/scraper/components/courses.ts b/src/scraper/components/courses.ts index df02615..5f4f677 100644 --- a/src/scraper/components/courses.ts +++ b/src/scraper/components/courses.ts @@ -9,7 +9,7 @@ export class CourseScraper extends ScraperComponent { room: RoomScrape, progress: number | undefined = undefined, ): Promise { - if (room.kusssId == null) throw "room.kusssId can not be null here"; + if (room.kusssId == null) throw Error("room.kusssId cannot be null here"); const url = this.scraper.kusssUrl + @@ -17,7 +17,7 @@ export class CourseScraper extends ScraperComponent { const ch: cheerio.CheerioAPI = await this.scraper.request(url); // select the elements in the table - const values = ch("div.contentcell > table > tbody") + const values = ch("div.contentcell > div.sectionheader > table > tbody") // select the last of them // then, select the children (rows) // then, remove the first row which is the header diff --git a/src/scraper/types.ts b/src/scraper/types.ts index 16bec70..e2b8996 100644 --- a/src/scraper/types.ts +++ b/src/scraper/types.ts @@ -86,14 +86,15 @@ export declare interface RoomToCapacityMap { [room: string]: number; } -export const SEARCH_PAGE = "/kusss/coursecatalogue-start.action?advanced=true"; +export const SEARCH_PAGE = + "/kusss/coursecatalogue-start.action?showFilters=true"; export const SEARCH_RESULTS = - "/kusss/coursecatalogue-search-lvas.action?sortParam0courses=lvaName&asccourses=true" + - "&detailsearch=true&advanced=%24advanced&lvaName=&abhart=all&organisationalHint=&lastname=&firstname=" + + "/kusss/coursecatalogue-searchlvareg.action?sortParam0courses=lvaName&asccourses=true" + + "&showFilters=true&lvasearch=&direct=true&lvaName=&abhart=all&organisationalHint=&lastname=&firstname=" + "&lvaNr=&klaId=&type=all&curriculumContentKey=all&orgid=Alle&language=all&day=all&timefrom=all&timeto=all" + - "&room={{room}}+&direct=true#result"; + "&room={{room}}"; export const COURSE_DETAILS = - "/kusss/selectcoursegroup.action?coursegroupid={{coursegroupid}}&showdetails={{showdetails}}" + + "/kusss/lvaregistrationlist.action?coursegroupid={{coursegroupid}}&showdetails={{showdetails}}" + "&abhart=all&courseclassid={{courseclassid}}"; export const BUILDINGS_PAGE = "/en/campus/the-jku-campus/buildings/";