Public
Edited
Mar 22, 2022
Importers
1 star
Insert cell
Insert cell
Insert cell
getWiki = (page) =>
fetch(
new URL("https://en.wikipedia.org/w/api.php?") +
new URLSearchParams({
action: "parse",
page: page,
prop: "text",
format: "json",
version: 2,
origin: "*"
}))
.then(response => response.json())
.then(data => data.parse.text["*"])
.then(text => (new DOMParser).parseFromString(text, "text/html"))
Insert cell
parseTable = (table) =>
[...table.querySelectorAll("tr:not(:first-child)")]
.map(r => [...r.querySelectorAll("td")].map(c => c.textContent.trim()))
.map(row => Object.fromEntries(
d3.zip(
[...table.querySelectorAll("th")].map(h => h.textContent.trim()),
row)));
Insert cell
parseNDJSON = (ndjson) =>
ndjson
.split("\n")
.filter(d => d != "")
.map(d => JSON.parse(d))
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more