const cheerio = require("cheerio"); const fetch = require("node-fetch"); 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; } module.exports = parseTeachers;