Skip to content

Commit

Permalink
Fix scraper because the KUSSS endpoints changed slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
blu3r4y committed Jun 13, 2024
1 parent c883343 commit 371d09e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/scraper/components/courses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ export class CourseScraper extends ScraperComponent<CourseScrape[]> {
room: RoomScrape,
progress: number | undefined = undefined,
): Promise<CourseScrape[]> {
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 +
SEARCH_RESULTS.replace("{{room}}", encodeURIComponent(room.kusssId));
const ch: cheerio.CheerioAPI = await this.scraper.request(url);

// select the <tbody> elements in the table
const values = ch("div.contentcell > table > tbody")
const values = ch("div.contentcell > div.sectionheader > table > tbody")
// select the last <tbody> of them
// then, select the <tr> children (rows)
// then, remove the first row which is the header
Expand Down
11 changes: 6 additions & 5 deletions src/scraper/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/";

0 comments on commit 371d09e

Please sign in to comment.