40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
/*
|
|
* 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";
|
|
|
|
globalThis.File = class File {};
|
|
|
|
export default async function parseTeachers() {
|
|
const url = "https://spsejecna.cz/ucitel";
|
|
const response = await fetch(url);
|
|
const data = await response.text(); // fetch needs .text() to get HTML
|
|
const $ = cheerio.load(data);
|
|
|
|
const map = {};
|
|
|
|
$("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"
|
|
map[key] = text;
|
|
}
|
|
});
|
|
|
|
return map;
|
|
}
|