functional programming
This commit is contained in:
parent
4b9311c61f
commit
f9a5d5cdac
1 changed files with 14 additions and 16 deletions
30
index.ts
30
index.ts
|
@ -14,24 +14,22 @@ async function getPatchHrefs() {
|
||||||
|
|
||||||
let patchHrefs: string[] = [];
|
let patchHrefs: string[] = [];
|
||||||
|
|
||||||
for (let i = 0; i <= 7; i++) {
|
[...Array(7).keys()]
|
||||||
const req = await fetch(getGalleryPageHref(i));
|
.map((val) => ++val)
|
||||||
const data = parse(await req.text());
|
.map(async (page) => {
|
||||||
|
const req = await fetch(getGalleryPageHref(page));
|
||||||
|
const data = parse(await req.text());
|
||||||
|
|
||||||
const gallery = data
|
const gallery = data
|
||||||
.getElementsByTagName("div")
|
.getElementsByTagName("div")
|
||||||
.filter((el) => el.classList.contains("hds-gallery-items"))
|
.filter((el) => el.classList.contains("hds-gallery-items"))
|
||||||
.shift();
|
.shift();
|
||||||
|
|
||||||
const links = gallery
|
return gallery
|
||||||
?.getElementsByTagName("a")
|
?.getElementsByTagName("a")
|
||||||
.map((el) => el.getAttribute("href"))
|
.map((el) => el.getAttribute("href"))
|
||||||
.filter((el) => el) as string[];
|
.filter((el) => el) as string[];
|
||||||
|
});
|
||||||
patchHrefs.push.apply(patchHrefs, links);
|
|
||||||
}
|
|
||||||
|
|
||||||
return patchHrefs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const allPatches = await getPatchHrefs();
|
const allPatches = await getPatchHrefs();
|
||||||
|
|
Loading…
Reference in a new issue