weibo,bilibili后添加hotband;修改html文件名
This commit is contained in:
@@ -6,7 +6,10 @@ const path = require('path');
|
||||
const fileUtils = require('./utils/fileUtils');
|
||||
const requestUtils = require('./utils/requestUtils');
|
||||
|
||||
const DATA_FOLDER = path.join(path.dirname(__dirname), process.env.DATA_FOLDER ?? 'data', 'bilibili');
|
||||
const API_URL = "https://app.bilibili.com/x/v2/search/trending/ranking";
|
||||
const SUB_FOLDER = "bilibili-hotband";
|
||||
|
||||
const DATA_FOLDER = path.join(path.dirname(__dirname), process.env.DATA_FOLDER ?? 'data', SUB_FOLDER);
|
||||
console.log("DATA_FOLDER", DATA_FOLDER);
|
||||
fileUtils.createFolder(DATA_FOLDER); // 程序运行就保证 data 目录存在
|
||||
|
||||
@@ -14,12 +17,12 @@ async function main() {
|
||||
let requestTimestamp = Date.now();
|
||||
let now = new Date(requestTimestamp + 8 * 3600 * 1000).toISOString();
|
||||
|
||||
let result = await requestUtils.getApiResult("https://app.bilibili.com/x/v2/search/trending/ranking");
|
||||
let result = await requestUtils.getApiResult(API_URL);
|
||||
if (result.code != 0) {
|
||||
console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), "bilibili", "请求成功,但服务器处理失败,正在重试。");
|
||||
result = await requestUtils.getApiResult("https://app.bilibili.com/x/v2/search/trending/ranking");
|
||||
console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,正在重试。");
|
||||
result = await requestUtils.getApiResult(API_URL);
|
||||
if (result.ok != 1) {
|
||||
console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), "bilibili", "请求成功,但服务器处理失败,保存失败信息。");
|
||||
console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,保存失败信息。");
|
||||
// ok 不为 1,那么久直接保存便于后续分析,不进行后续处理
|
||||
fileUtils.saveJSON({
|
||||
saveFolder: DATA_FOLDER,
|
||||
@@ -33,7 +36,7 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), "bilibili", "请求成功");
|
||||
console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功");
|
||||
// console.log("result", result);
|
||||
|
||||
let data = result.data;
|
||||
|
@@ -6,7 +6,10 @@ const path = require('path');
|
||||
const fileUtils = require('./utils/fileUtils');
|
||||
const requestUtils = require('./utils/requestUtils');
|
||||
|
||||
const DATA_FOLDER = path.join(path.dirname(__dirname), process.env.DATA_FOLDER ?? 'data', 'weibo');
|
||||
const API_URL = "https://weibo.com/ajax/statuses/hot_band";
|
||||
const SUB_FOLDER = "weibo-hotband";
|
||||
|
||||
const DATA_FOLDER = path.join(path.dirname(__dirname), process.env.DATA_FOLDER ?? 'data', SUB_FOLDER);
|
||||
console.log("DATA_FOLDER", DATA_FOLDER);
|
||||
fileUtils.createFolder(DATA_FOLDER); // 程序运行就保证 data 目录存在
|
||||
|
||||
@@ -14,12 +17,12 @@ async function main() {
|
||||
let requestTimestamp = Date.now();
|
||||
let now = new Date(requestTimestamp + 8 * 3600 * 1000).toISOString();
|
||||
|
||||
let result = await requestUtils.getApiResult("https://weibo.com/ajax/statuses/hot_band");
|
||||
let result = await requestUtils.getApiResult(API_URL);
|
||||
if (result.ok != 1) {
|
||||
console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), "weibo", "请求成功,但服务器处理失败,正在重试。");
|
||||
result = await requestUtils.getApiResult("https://weibo.com/ajax/statuses/hot_band");
|
||||
console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,正在重试。");
|
||||
result = await requestUtils.getApiResult(API_URL);
|
||||
if (result.ok != 1) {
|
||||
console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), "weibo", "请求成功,但服务器处理失败,保存失败信息。");
|
||||
console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功,但服务器处理失败,保存失败信息。");
|
||||
// ok 不为 1,那么久直接保存便于后续分析,不进行后续处理
|
||||
fileUtils.saveJSON({
|
||||
saveFolder: DATA_FOLDER,
|
||||
@@ -33,7 +36,7 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), "weibo", "请求成功");
|
||||
console.log(new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString(), SUB_FOLDER, "请求成功");
|
||||
// console.log("result", result);
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user