Skip to content

Instantly share code, notes, and snippets.

@GitHub30
Last active June 2, 2022 12:28
Show Gist options
  • Save GitHub30/1381710ffb2e35238d69ed9f57d89b5d to your computer and use it in GitHub Desktop.
Save GitHub30/1381710ffb2e35238d69ed9f57d89b5d to your computer and use it in GitHub Desktop.
const parse = url => fetch(url).then(r=>r.text()).then(html=>new DOMParser().parseFromString(html,'text/html'))
const docs = [await parse('https://www.cloudskillsboost.google/catalog?skill-badge%5B%5D=skill-badge')]
while(docs.at(-1).querySelector('[rel="next"]')) docs.push(await parse(docs.at(-1).querySelector('[rel="next"]')?.href))
const questUrls = docs.flatMap(doc => [...doc.querySelectorAll('[href^="/quests/"]')]).map(a => a.href)
const questDocs = []
for await (const questUrl of questUrls) questDocs.push(await parse(questUrl))
questDocs.flatMap(doc => [...doc.querySelectorAll('h3>[href^="/focuses"]')]).filter(a=>a.textContent.includes('チャレンジラボ')).map(a=>a.textContent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment