Files
davisfe.cz/testScrape.js
T

25 lines
595 B
JavaScript

import axios from 'axios';
import * as cheerio from 'cheerio';
import https from 'https';
async function test() {
const agent = new https.Agent({ rejectUnauthorized: false });
try {
const res = await axios.get('https://www.pvl.cz/portal/nadrze/cz/pc/Nadrze.aspx', {
httpsAgent: agent,
headers: {
'User-Agent': 'Mozilla/5.0'
}
});
const $ = cheerio.load(res.data);
const rows = $('table tr');
rows.each((i, row) => {
console.log($(row).text().replace(/\s+/g, ' '));
});
} catch (e) {
console.error(e.message);
}
}
test();