From 5035bee159645ddf27cb7a5e21158d47f4ccc2ca Mon Sep 17 00:00:00 2001 From: pxskm4tvn <2836285168@qq.com> Date: Wed, 18 Sep 2024 00:06:08 +0800 Subject: [PATCH] ADD file via upload --- 主函数.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 主函数.md diff --git a/主函数.md b/主函数.md new file mode 100644 index 0000000..a5eabf5 --- /dev/null +++ b/主函数.md @@ -0,0 +1,34 @@ +```javascript +async function main() { + // 爬取第1页到第10页的视频BV号 + for (let i = 1; i <= 10; i++) { + await getBv(i); + } + console.log("BV列表长度:", bvList.length); + + // 将BV号写入本地文件 + fs.writeFileSync('bv.txt', bvList.join('\n'), 'utf-8'); + + // 对于每个BV号,爬取CID号 + bvList.forEach(bv => { + getCid(bv); + }); + console.log("CID列表长度:", cidList.length); + + // 将CID号写入本地文件 + fs.writeFileSync('cid.txt', cidList.join('\n'), 'utf-8'); + + // 对于每个 + +CID号,爬取弹幕内容 +cidList.forEach(cid => { +getChat(cid); +}); +console.log("弹幕内容列表长度:", chatList.length); + +// 将弹幕内容写入本地文件 +fs.writeFileSync('chat.txt', chatList.join('\n'), 'utf-8'); +} + +main(); +```