1
0

refactor: Rewrite to typescript
All checks were successful
Remote Deploy / deploy (push) Successful in 14s

This commit is contained in:
2026-02-11 08:20:56 +01:00
parent 138fa17e54
commit ae17dc241a
14 changed files with 941 additions and 121 deletions

View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2025 Jakub Žitník
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
import * as cheerio from "cheerio";
// @ts-ignore
globalThis.File = class File {};
export default async function parseTeachers(): Promise<Record<string, string>> {
const url = "https://spsejecna.cz/ucitel";
const response = await fetch(url);
const data = await response.text();
const $ = cheerio.load(data);
const map: Record<string, string> = {};
$("main .contentLeftColumn li, main .contentRightColumn li").each((_, el) => {
const link = $(el).find("a");
const href = link.attr("href"); // e.g. "/ucitel/PA"
const text = link.text().trim(); // e.g. "Ing. Bc. Šárka Páltiková"
if (href) {
const key = href.split("/").pop()?.toLowerCase(); // get "pa"
if (key) {
map[key] = text;
}
}
});
return map;
}