prague-blockchain-week/data/23/events/btcprague/_sync.js

20 řádky
696 B
JavaScript
Surový Normální zobrazení Historie

2023-01-23 04:37:12 +01:00
export async function data(tools) {
const $ = await tools.loadHtmlUrl("https://www.btcprague.com/");
const out = { speakers: [] };
for (const el of $(".speaker").toArray()) {
const value = (path) => cleanup($(path, el).text());
out.speakers.push({
2023-01-24 02:44:48 +01:00
id: value("h3").toLowerCase().replace(/ /g, "-").trim(),
2023-01-23 04:37:12 +01:00
name: value("h3"),
photoUrl: $("img", el).attr("src"),
bio: value(".popis"),
twitter: $(".twitter", el).attr("href")?.replace("https://twitter.com/",""),
2023-01-23 04:51:17 +01:00
web: $(".www", el).attr("href") ? { url: $(".www", el).attr("href") } : undefined,
2023-01-23 04:37:12 +01:00
});
}
return out;
}
2023-01-23 04:51:17 +01:00
function cleanup(str) {
return str.replace(/(\s{2,}|\n)/g, " ").trim();
}