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