Skip to content

Instantly share code, notes, and snippets.

@basst85
Created January 26, 2021 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save basst85/5347a54799607522917f146d732084a3 to your computer and use it in GitHub Desktop.
Save basst85/5347a54799607522917f146d732084a3 to your computer and use it in GitHub Desktop.
covid-19_vaccins_nl.js
let https = require("https");
let jsdom = require("jsdom");
// Get page
https.get("https://coronadashboard.rijksoverheid.nl", (res) => {
let htmlData;
res.on("data", (chunk) => {
htmlData += chunk;
});
// Get HTML-data
res.on("end", () => {
let dom = new jsdom.JSDOM(htmlData);
// Get JSON-string from HTML
let jsonString = dom.window.document.getElementById("__NEXT_DATA__").textContent;
// Parse string as JSON
let jsonData = JSON.parse(jsonString);
// Get vaccinaties data
let vaccinaties = jsonData.props.pageProps.text.vaccinaties
let kpi_total = vaccinaties.data.kpi_total;
let dateOfInsertion = new Date(vaccinaties.date_of_insertion_unix * 1000);
console.log("Last update : ", dateOfInsertion);
console.log(kpi_total.title, ":", kpi_total.value);
});
}).on("error", (e) => {
console.error(e);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment