update
This commit is contained in:
@@ -14,7 +14,7 @@ const dataManager = require('../dataManager');
|
||||
|
||||
async function fetchAll({ args }) {
|
||||
// 睡眠时间设置长一些,不然容易触发500错误
|
||||
global.sleepTime = Math.max(500, global.sleepTime);
|
||||
global.sleepTime = Math.max(1000, global.sleepTime);
|
||||
console.log("global.sleepTime", global.sleepTime);
|
||||
console.log("playlist 需要一口气爬完,中途不能停止,否则下次又要重头爬(歌单不会重复爬取,但是分页列表会)");
|
||||
|
||||
@@ -28,8 +28,8 @@ async function fetchAll({ args }) {
|
||||
for (let i = 0; i < cate.length; i++) {
|
||||
const categoryName = cate[i];
|
||||
try {
|
||||
console.log("开始爬取分类:", categoryName);
|
||||
await fetchCategory({ categoryName: categoryName, progress: `${i + 1}/${cate.length}` });
|
||||
console.log(`开始爬取分类:${categoryName}(i=${i})`);
|
||||
await fetchCategory({ categoryName: `${categoryName}`, progress: `${i + 1}/${cate.length}` });
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
@@ -94,7 +94,10 @@ async function fetchCategory({ categoryName, progress }) {
|
||||
}
|
||||
} else {
|
||||
console.log("失败url", url);
|
||||
fs.writeFileSync(path.join(__dirname, "../../temp", `[error]discover-playlist.html`), html);
|
||||
await dbUtils.query('INSERT INTO log (`id`, `name`, `msg`) VALUES (?, ?, ?)', [0, 'playlist_fetch', `失败 可能是爬太快了\n${url}`]);
|
||||
await sleepUtils.sleep(40 * 1000); // 等待40s再继续爬取
|
||||
continue;
|
||||
}
|
||||
|
||||
// 最有一页判断标识
|
||||
|
Reference in New Issue
Block a user