Created
June 20, 2022 20:36
-
-
Save stevekrouse/6c0729c01a4194c0379e31b8cdfc6dfb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this function needs to be run on `http://daystareld.com` because of CORS | |
async function doIt() { | |
const url = "http://daystareld.com/pokemon-" | |
const maxChapter = 105 | |
const numbers = [...Array(maxChapter).keys()].map(n => n+1) | |
const urls = numbers.map(n => `${url}${n}/`) | |
const pages = await Promise.all(urls.map(u => fetch(u).then(r => r.text()))) | |
const output = pages.map(p => { | |
const el = document.createElement( 'html' ); | |
el.innerHTML = p | |
const title = el.getElementsByClassName('entry-title')[0].innerText | |
const body = el.getElementsByClassName('entry-content')[0].innerText | |
return title + "\n\n" + body; | |
}).join("\n\n").replaceAll(/\n\n(\n)*/g, "\n\n").replaceAll("\t", "").replaceAll(/.*(«|»).*\n/g, "") | |
console.log(output) | |
// then press the `copy` button on this output | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment