Created
February 19, 2023 17:13
-
-
Save vaaas/7da28f5db698b59dcc61f5f965721103 to your computer and use it in GitHub Desktop.
Fetch the authors of favourited works in pixiv
This file contains 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
const max_page = 0 | |
const version = '' | |
const user = '' | |
const make_url = (x) => `https://www.pixiv.net/ajax/user/${user}/illusts/bookmarks?tag=&offset=${x*48}&limit=48&rest=show&lang=en&version=${version}` | |
function* seq(start, end) { | |
for (let i = start; i <= end; i++) | |
yield i | |
} | |
const sleep = ms => new Promise(yes => setTimeout(() => yes(), ms)) | |
const get_user_ids = x => x.body.works.map(x => x.userId) | |
async function main() { | |
const users = new Set() | |
for (const i of seq(0, max_page)) { | |
const data = await fetch(make_url(i)).then(x => x.json()) | |
for (const x of get_user_ids(data)) | |
users.add(x) | |
await sleep(5000) | |
} | |
console.log(Array.from(users).sort()) | |
} | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment