Public
Edited
May 17, 2024
2 forks
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = {
let result = [];
let offset = "";
while (offset !== undefined) {
let data = await get_pagescreated({
username: username,
wikipedia: wikipedia,
offset: offset
});
offset = data.continue;
result = result.concat(aq.from(Object.values(data.pages[0])));
yield result;
}
return result;
}
Insert cell
df = data[0].union(data)
Insert cell
Inputs.table(df, { columns: ["namespace", "page_title"] })
Insert cell
results = await Promise.all(
df.array("page_title").map((d) =>
get_prose({
article: d,
wikipedia: wikipedia
})
)
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
get_prose0 = ({ article, wikipedia = "en.wikipedia.org" }) => {
return fetch(
`https://xtools.wmcloud.org/api/page/prose/` + wikipedia + `/` + article
).then((d) => d.json());
}
Insert cell
get_prose0({
article: "Format à l'italienne",
wikipedia: "fr.wikipedia.org"
})
Insert cell
get_prose = ({ article, wikipedia = "en.wikipedia.org" }) => {
return fetch(
`https://xtools.wmcloud.org/api/page/prose/` + wikipedia + `/` + article
)
.then((d) => d.json())
.then((d) =>
aq.table({
article: [article],
characters: [d["characters"]],
words: [d["words"]],
references: [d["references"]],
unique_references: [d["unique_references"]],
sections: [d["sections"]]
})
);
}
Insert cell
get_prose({
article: "Economics",
wikipedia: "en.wikipedia.org"
}).then((d) => d.view())
Insert cell
Insert cell
get_pagescreated = async function ({ username, wikipedia, offset = "" }) {
return d3.json(
"https://xtools.wmcloud.org/api/user/pages/" +
wikipedia +
"/" +
username +
"/0/noredirects/live///" +
offset
);
}
Insert cell
test = get_pagescreated({ username: "PAC2", wikipedia: "fr.wikipedia.org" })
Insert cell
aq.from(test.pages[0]).view()
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