Public
Edited
May 17, 2024
2 forks
Importers
1 star
Also listed in…
Wikipedia tools
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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more