1
0
Files
jecnarozvrh/scrape/utils/parseTeachers.js
jzitnik-dev 4985d574d5
All checks were successful
Remote Deploy / deploy (push) Successful in 4s
feat: Absences
2025-08-31 16:35:22 +02:00

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;