Files
davisfe.cz/scripts/fetch_lakes_temp.ts
T
David Fencl a67a2247c3
continuous-integration/drone/push Build encountered an error
feat: import new reservoir data, add lake management scripts, and update overview UI components
2026-06-06 20:14:36 +02:00

34 lines
869 B
TypeScript

import axios from 'axios';
import * as cheerio from 'cheerio';
import https from 'https';
async function fetchLakes() {
const agent = new https.Agent({ rejectUnauthorized: false });
try {
const response = await axios.get('https://www.pvl.cz/portal/nadrze/cz/pc/Prehled.aspx', {
httpsAgent: agent,
headers: {
'User-Agent': 'Mozilla/5.0'
}
});
const $ = cheerio.load(response.data);
const lakes: any[] = [];
// Links to lakes usually look like Mereni.aspx?oid=xxx&id=yyy
$('a[href^="Mereni.aspx"]').each((i, el) => {
const href = $(el).attr('href');
const text = $(el).text().trim();
if (href && text) {
lakes.push({ href, text });
}
});
console.log(JSON.stringify(lakes, null, 2));
} catch (err: any) {
console.error('Error:', err.message);
}
}
fetchLakes();