Created
January 26, 2021 15:38
-
-
Save basst85/5347a54799607522917f146d732084a3 to your computer and use it in GitHub Desktop.
covid-19_vaccins_nl.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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