weibo,bilibili后添加hotband;修改html文件名
This commit is contained in:
parent
05ea84f47e
commit
5bb9ac6235
@ -192,7 +192,7 @@
|
|||||||
|
|
||||||
function getData() {
|
function getData() {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open("GET", "../data/bilibili/latest.json?t=" + Date.now(), true);
|
xhr.open("GET", "../data/bilibili-hotband/latest.json?t=" + Date.now(), true);
|
||||||
xhr.send();
|
xhr.send();
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
if (xhr.readyState !== 4) return;
|
if (xhr.readyState !== 4) return;
|
@ -201,7 +201,7 @@
|
|||||||
|
|
||||||
function getData() {
|
function getData() {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open("GET", "../data/weibo/latest.json?t=" + Date.now(), true);
|
xhr.open("GET", "../data/weibo-hotband/latest.json?t=" + Date.now(), true);
|
||||||
xhr.send();
|
xhr.send();
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
if (xhr.readyState !== 4) return;
|
if (xhr.readyState !== 4) return;
|
@ -74,11 +74,11 @@
|
|||||||
<!-- <iframe src="html/weibo.html" frameborder="0"></iframe> -->
|
<!-- <iframe src="html/weibo.html" frameborder="0"></iframe> -->
|
||||||
</div>
|
</div>
|
||||||
<div id="float-container" class="bt">
|
<div id="float-container" class="bt">
|
||||||
<div class="navbar-item" targetPage="weibo">
|
<div class="navbar-item" targetPage="weibo_hotband">
|
||||||
<img class="navbar-image" src="./html/assets/image/weibo.svg" />
|
<img class="navbar-image" src="./html/assets/image/weibo.svg" />
|
||||||
<p class="navbar-title">微博</p>
|
<p class="navbar-title">微博</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="navbar-item" targetPage="bilibili">
|
<div class="navbar-item" targetPage="bilibili_hotband">
|
||||||
<img class="navbar-image" src="./html/assets/image/bilibili.svg" style="transform: scale(0.84);" />
|
<img class="navbar-image" src="./html/assets/image/bilibili.svg" style="transform: scale(0.84);" />
|
||||||
<p class="navbar-title">B站</p>
|
<p class="navbar-title">B站</p>
|
||||||
</div>
|
</div>
|
||||||
@ -123,7 +123,7 @@
|
|||||||
|
|
||||||
// 根据 URL 参数切换页面
|
// 根据 URL 参数切换页面
|
||||||
function locationToPageByUrlParam() {
|
function locationToPageByUrlParam() {
|
||||||
let pages = ['weibo', 'bilibili'];
|
let pages = ['weibo_hotband', 'bilibili_hotband'];
|
||||||
// 获取 url 中的 target 参数
|
// 获取 url 中的 target 参数
|
||||||
let url = new URL(window.location.href);
|
let url = new URL(window.location.href);
|
||||||
let target = url.searchParams.get('target');
|
let target = url.searchParams.get('target');
|
||||||
|
@ -6,7 +6,10 @@ const path = require('path');
|
|||||||
const fileUtils = require('./utils/fileUtils');
|
const fileUtils = require('./utils/fileUtils');
|
||||||
const requestUtils = require('./utils/requestUtils');
|
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);
|
console.log("DATA_FOLDER", DATA_FOLDER);
|
||||||
fileUtils.createFolder(DATA_FOLDER); // 程序运行就保证 data 目录存在
|
fileUtils.createFolder(DATA_FOLDER); // 程序运行就保证 data 目录存在
|
||||||
|
|
||||||
@ -14,12 +17,12 @@ async function main() {
|
|||||||
let requestTimestamp = Date.now();
|
let requestTimestamp = Date.now();
|
||||||
let now = new Date(requestTimestamp + 8 * 3600 * 1000).toISOString();
|
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) {
|
if (result.code != 0) {
|
||||||
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, "请求成功,但服务器处理失败,正在重试。");
|
||||||
result = await requestUtils.getApiResult("https://app.bilibili.com/x/v2/search/trending/ranking");
|
result = await requestUtils.getApiResult(API_URL);
|
||||||
if (result.ok != 1) {
|
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,那么久直接保存便于后续分析,不进行后续处理
|
// ok 不为 1,那么久直接保存便于后续分析,不进行后续处理
|
||||||
fileUtils.saveJSON({
|
fileUtils.saveJSON({
|
||||||
saveFolder: DATA_FOLDER,
|
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);
|
// console.log("result", result);
|
||||||
|
|
||||||
let data = result.data;
|
let data = result.data;
|
||||||
|
@ -6,7 +6,10 @@ const path = require('path');
|
|||||||
const fileUtils = require('./utils/fileUtils');
|
const fileUtils = require('./utils/fileUtils');
|
||||||
const requestUtils = require('./utils/requestUtils');
|
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);
|
console.log("DATA_FOLDER", DATA_FOLDER);
|
||||||
fileUtils.createFolder(DATA_FOLDER); // 程序运行就保证 data 目录存在
|
fileUtils.createFolder(DATA_FOLDER); // 程序运行就保证 data 目录存在
|
||||||
|
|
||||||
@ -14,12 +17,12 @@ async function main() {
|
|||||||
let requestTimestamp = Date.now();
|
let requestTimestamp = Date.now();
|
||||||
let now = new Date(requestTimestamp + 8 * 3600 * 1000).toISOString();
|
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) {
|
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, "请求成功,但服务器处理失败,正在重试。");
|
||||||
result = await requestUtils.getApiResult("https://weibo.com/ajax/statuses/hot_band");
|
result = await requestUtils.getApiResult(API_URL);
|
||||||
if (result.ok != 1) {
|
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,那么久直接保存便于后续分析,不进行后续处理
|
// ok 不为 1,那么久直接保存便于后续分析,不进行后续处理
|
||||||
fileUtils.saveJSON({
|
fileUtils.saveJSON({
|
||||||
saveFolder: DATA_FOLDER,
|
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);
|
// console.log("result", result);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user