You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I do these one at a time they all resolve with a page, when I do more than ten at a time they start to throw pageerrors. I made a little code sample that perfectly illustrates the issue:
const wiki = require('wikipedia');
const subjects = [ "University of Washington", "USC Gould School of Law", "Watergate", "Supreme Court", "Justice Clarence Thomas", "Harlan Crow", "resignation", "impeachment", "public trust", "code of ethics", "University of Washington", "USC Gould School of Law", "Watergate", "Supreme Court", "Justice Clarence Thomas", "Harlan Crow", "resignation", "impeachment", "public trust", "code of ethics" ];
async function GetWikiSummary(subject) {
let result = {};
try {
result.subject = subject;
const page = await wiki.page(subject);
result.canonicalurl = page.canonicalurl;
} catch (error) {
result.error = error;
}
return result;
}
async function getWikiSummaries(subjects) {
const results = [];
for (const subject of subjects) {
try {
const summary = await GetWikiSummary(subject);
results.push(summary);
} catch (error) {
results.push({ subject });
}
}
return results;
}
console.log("Starting");
(async () => {
const converted = await getWikiSummaries(subjects);
//const converted = await GetWikiSummary('impeachment');
console.log(JSON.stringify(converted, null, 2));
})();
console.log("Done");
the list is actually duplicated items to show that the first 10 resolve and the last 10 (even though they are the same) will throw page errors. If I have a lost of 20 items what is the recommended way to get 20?
When I do these one at a time they all resolve with a page, when I do more than ten at a time they start to throw pageerrors. I made a little code sample that perfectly illustrates the issue:
the list is actually duplicated items to show that the first 10 resolve and the last 10 (even though they are the same) will throw page errors. If I have a lost of 20 items what is the recommended way to get 20?
the result of the above code looks like this:
Thanks for the help!
The text was updated successfully, but these errors were encountered: