diff --git a/hotband/src/get_bilibili_hotband.js b/hotband/src/get_bilibili_hotband.js index 7da0f90..1d4cb72 100644 --- a/hotband/src/get_bilibili_hotband.js +++ b/hotband/src/get_bilibili_hotband.js @@ -18,12 +18,20 @@ async function main() { let now = new Date(requestTimestamp + 8 * 3600 * 1000).toISOString(); let result = await requestUtils.getApiResult(API_URL); + if (result === undefined) { + console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求失败"); + return; + } if (result.code != 0) { console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,等待3s后重试。"); await new Promise((resolve) => { setTimeout(resolve, 3000); // 等待3秒 }); result = await requestUtils.getApiResult(API_URL); + if (result === undefined) { + console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "重试请求失败"); + return; + } if (result.ok != 1) { console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,保存失败信息。"); // ok 不为 1,那么久直接保存便于后续分析,不进行后续处理 diff --git a/hotband/src/get_bilibili_rank.js b/hotband/src/get_bilibili_rank.js index 01be364..60b7114 100644 --- a/hotband/src/get_bilibili_rank.js +++ b/hotband/src/get_bilibili_rank.js @@ -18,12 +18,20 @@ async function main() { let now = new Date(requestTimestamp + 8 * 3600 * 1000).toISOString(); let result = await requestUtils.getApiResult(API_URL); + if (result === undefined) { + console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求失败"); + return; + } if (result.code != 0) { console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,等待3s后重试。"); await new Promise((resolve) => { setTimeout(resolve, 3000); // 等待3秒 }); result = await requestUtils.getApiResult(API_URL); + if (result === undefined) { + console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "重试请求失败"); + return; + } if (result.ok != 1) { console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,保存失败信息。"); // ok 不为 1,那么久直接保存便于后续分析,不进行后续处理 diff --git a/hotband/src/get_weibo_hotband.js b/hotband/src/get_weibo_hotband.js index cd0fcee..b5bfbd7 100644 --- a/hotband/src/get_weibo_hotband.js +++ b/hotband/src/get_weibo_hotband.js @@ -18,12 +18,20 @@ async function main() { let now = new Date(requestTimestamp + 8 * 3600 * 1000).toISOString(); let result = await requestUtils.getApiResult(API_URL); + if (result === undefined) { + console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求失败"); + return; + } if (result.ok != 1) { console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,等待3s后重试。"); await new Promise((resolve) => { setTimeout(resolve, 3000); // 等待3秒 }); result = await requestUtils.getApiResult(API_URL); + if (result === undefined) { + console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "重试请求失败"); + return; + } if (result.ok != 1) { console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,保存失败信息。"); // ok 不为 1,那么就直接保存便于后续分析,不进行后续处理 diff --git a/hotband/src/utils/requestUtils.js b/hotband/src/utils/requestUtils.js index d2547df..807b310 100644 --- a/hotband/src/utils/requestUtils.js +++ b/hotband/src/utils/requestUtils.js @@ -14,7 +14,7 @@ async function getApiResult(url) { } else { // 请求失败 console.log(`error is ${error}`); - resolve({}); + resolve(undefined); } }); });