26 lines
670 B
JavaScript
26 lines
670 B
JavaScript
const { default: axios } = require("axios");
|
|
const cheerio = require("cheerio");
|
|
|
|
async function parseTeachers() {
|
|
const url = "https://spsejecna.cz/ucitel";
|
|
const { data } = await axios.get(url);
|
|
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;
|
|
}
|
|
|
|
module.exports = parseTeachers;
|