|
|
|
@ -49,6 +49,7 @@ import path from 'node:path';
@@ -49,6 +49,7 @@ import path from 'node:path';
|
|
|
|
|
//spider run
|
|
|
|
|
let spider_is_running = false, |
|
|
|
|
last_run_time = 0; |
|
|
|
|
let last_douyin_mode = 'pc'; |
|
|
|
|
const task_check_time = 20; //每 20 秒抓取一次
|
|
|
|
|
const task_auto_run = cron.schedule(`*/${task_check_time} * * * * *`, async () => { |
|
|
|
|
const current_time = common.getTimestampInSeconds(); |
|
|
|
@ -70,6 +71,7 @@ import path from 'node:path';
@@ -70,6 +71,7 @@ import path from 'node:path';
|
|
|
|
|
switch (botName) { |
|
|
|
|
case 'douyin': |
|
|
|
|
bot = new Douyin(heroCloudServer); |
|
|
|
|
bot.setMode(last_douyin_mode); |
|
|
|
|
break; |
|
|
|
|
case 'kuaishou': |
|
|
|
|
bot = new Kuaishou(heroCloudServer); |
|
|
|
@ -90,6 +92,11 @@ import path from 'node:path';
@@ -90,6 +92,11 @@ import path from 'node:path';
|
|
|
|
|
const data = await bot.scrap(task.url); |
|
|
|
|
//console.log('Data got by bot', data);
|
|
|
|
|
|
|
|
|
|
//为抖音切换模式
|
|
|
|
|
if (bot.name == 'douyin') { |
|
|
|
|
last_douyin_mode = last_douyin_mode == 'pc' ? 'mob' : 'pc'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (typeof(data.done) != 'undefined' && data.done == true) { |
|
|
|
|
task.data = data; //把抓取到的数据保存到任务里
|
|
|
|
|
taskMoniter.updateTask(task.id, task); |
|
|
|
|