matching urls to descriptions
This commit is contained in:
parent
8023f5a0e5
commit
6d890304a2
1 changed files with 10 additions and 4 deletions
14
index.ts
14
index.ts
|
@ -38,15 +38,21 @@ async function getPatchHrefs() {
|
||||||
|
|
||||||
const allPatches = await getPatchHrefs();
|
const allPatches = await getPatchHrefs();
|
||||||
|
|
||||||
const patchRequests = allPatches.map((testPatchUrl) =>
|
const patchRequests = allPatches.map((url) =>
|
||||||
(async () => {
|
(async () => {
|
||||||
const req = await fetch(testPatchUrl);
|
const req = await fetch(url);
|
||||||
const data = parse(await req.text());
|
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 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);
|
console.log(patchDescriptions);
|
||||||
|
|
Loading…
Reference in a new issue