通过命令行指定爬取参数,不用再修改代码了
This commit is contained in:
@@ -13,7 +13,7 @@ global.dbUtils = dbUtils;
|
||||
console.log("global.useMysqlPool:", !!global.useMysqlPool);
|
||||
|
||||
// 两次请求之间停顿时间
|
||||
global.sleepTime = 300;
|
||||
global.sleepTime = 10;
|
||||
|
||||
// 引入utils
|
||||
const songInfoUtils = require('./src/getInfo/songInfoUtils');
|
||||
@@ -46,7 +46,7 @@ async function test() {
|
||||
/**
|
||||
* 主函数
|
||||
*/
|
||||
async function main() {
|
||||
async function main(args) {
|
||||
console.log("neteaseMusic Start fetch ...");
|
||||
while (true) {
|
||||
// // 删除脏数据
|
||||
@@ -54,11 +54,20 @@ async function main() {
|
||||
// var affectedRows2 = await dbUtils.query(`DELETE FROM song_album_relation WHERE song_id = 0 OR album_id = 0`, []);
|
||||
// console.log(`删除脏数据 affectedRows:`, affectedRows1.affectedRows, affectedRows2.affectedRows);
|
||||
|
||||
await songInfoUtils.fetchAll();
|
||||
await albumInfoUtils.fetchAll({});
|
||||
await artistInfoUtils.fetchAll();
|
||||
await lyricInfoUtils.fetchAll();
|
||||
await commentUtils.fetchAll();
|
||||
if (args.utils == "song")
|
||||
await songInfoUtils.fetchAll({ args: args });
|
||||
else if (args.utils == "album")
|
||||
await albumInfoUtils.fetchAll({ args: args });
|
||||
else if (args.utils == "artist")
|
||||
await artistInfoUtils.fetchAll({ args: args });
|
||||
else if (args.utils == "lyric")
|
||||
await lyricInfoUtils.fetchAll({ args: args });
|
||||
else if (args.utils == "comment")
|
||||
await commentUtils.fetchAll({ args: args });
|
||||
else {
|
||||
console.log("utils参数不匹配,退出");
|
||||
return;
|
||||
}
|
||||
await sleepUtils.sleep(2000);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user