matching urls to descriptions

main
Zynh0722 2024-04-02 23:59:41 -07:00
parent 8023f5a0e5
commit 6d890304a2
1 changed files with 10 additions and 4 deletions

View File

@ -38,15 +38,21 @@ async function getPatchHrefs() {
const allPatches = await getPatchHrefs();
const patchRequests = allPatches.map((testPatchUrl) =>
const patchRequests = allPatches.map((url) =>
(async () => {
const req = await fetch(testPatchUrl);
const req = await fetch(url);
const data = parse(await req.text());
return data.getElementsByTagName("h1")[0].nextElementSibling?.innerText;
return {
url,
description:
data.getElementsByTagName("h1")[0].nextElementSibling?.innerText,
};
})(),
);
const dirtyPatchDescriptions = await Promise.all(patchRequests);
const patchDescriptions = dirtyPatchDescriptions.filter((e) => e) as string[];
const patchDescriptions = dirtyPatchDescriptions.filter(
({ description }) => description,
) as { url: string; description: string }[];
console.log(patchDescriptions);