Skip to content

Commit

Permalink
feat: 奇遇生成脚本自动处理分页
Browse files Browse the repository at this point in the history
  • Loading branch information
tinymins committed Sep 25, 2023
1 parent 717dde9 commit 7c37e35
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions build/generate_serendipity.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,21 @@ const main = async () => {
const type = TYPE_LIST[i];
for (let j = 0; j < CLIENT_LIST.length; j++) {
const client = CLIENT_LIST[j];
const res = await Axios({
url: `https://node.jx3box.com/serendipities?type=${type}&page=1&client=${client}&per=50`,
});
console.log(`${type} ${client}: ${res.data.list.reverse().map(d => d.szName).join(', ')}`);
let list = [];
let page = 1;
while (true) {
const res = await Axios({
url: `https://node.jx3box.com/serendipities?type=${type}&page=${page}&client=${client}&per=50`,
});
list = [...list, ...res.data.list];
if (res.data.page >= res.data.pages) {
page = 1;
break;
} else {
page += 1;
}
}
console.log(`${type} ${client}: ${list.reverse().map(d => d.szName).join(', ')}`);
}
}
};
Expand Down

0 comments on commit 7c37e35

Please sign in to comment.