feat: 新增豆瓣新片榜 & add ESLint
This commit is contained in:
parent
813e88c993
commit
6330914d09
19
.eslintrc.json
Normal file
19
.eslintrc.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es2021": true
|
||||||
|
},
|
||||||
|
"extends": ["eslint:recommended", "plugin:vue/vue3-essential"],
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": "latest",
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": ["vue"],
|
||||||
|
"rules": {},
|
||||||
|
"globals": {
|
||||||
|
"require": true,
|
||||||
|
"module": true,
|
||||||
|
"process": true,
|
||||||
|
"__dirname": true
|
||||||
|
}
|
||||||
|
}
|
8
.prettierrc.json
Normal file
8
.prettierrc.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/prettierrc",
|
||||||
|
"singleQuote": false,
|
||||||
|
"trailingComma": "all",
|
||||||
|
"tabWidth": 2,
|
||||||
|
"semi": true,
|
||||||
|
"printWidth": 100
|
||||||
|
}
|
@ -24,9 +24,10 @@
|
|||||||
| 百度 | 热搜榜 | baidu | 🟢 |
|
| 百度 | 热搜榜 | baidu | 🟢 |
|
||||||
| 抖音 | 热点榜 | douyin / douyin_new | 🟢 |
|
| 抖音 | 热点榜 | douyin / douyin_new | 🟢 |
|
||||||
| 抖音 | 热歌榜 | douyin_music | 🟢 |
|
| 抖音 | 热歌榜 | douyin_music | 🟢 |
|
||||||
|
| 豆瓣 | 新片榜 | douban_new | 🟢 |
|
||||||
| 百度贴吧 | 热议榜 | tieba | 🟢 |
|
| 百度贴吧 | 热议榜 | tieba | 🟢 |
|
||||||
| 少数派 | 热榜 | sspai | 🟢 |
|
| 少数派 | 热榜 | sspai | 🟢 |
|
||||||
| IT 之家 | 热榜 | ithome | 🟢 |
|
| IT 之家 | 热榜 | ithome | 🟠 |
|
||||||
| 澎湃新闻 | 热榜 | thepaper | 🟢 |
|
| 澎湃新闻 | 热榜 | thepaper | 🟢 |
|
||||||
| 今日头条 | 热榜 | toutiao | 🟢 |
|
| 今日头条 | 热榜 | toutiao | 🟢 |
|
||||||
| 36 氪 | 热榜 | 36kr | 🟢 |
|
| 36 氪 | 热榜 | 36kr | 🟢 |
|
||||||
@ -59,7 +60,7 @@ GET https://example.com/calendar/date?month=06&day=01
|
|||||||
|
|
||||||
## 部署
|
## 部署
|
||||||
|
|
||||||
```js
|
```bash
|
||||||
// 安装依赖
|
// 安装依赖
|
||||||
pnpm install
|
pnpm install
|
||||||
|
|
||||||
|
2
index.js
2
index.js
@ -24,7 +24,7 @@ app.use(views(__dirname + "/public"));
|
|||||||
app.use(
|
app.use(
|
||||||
cors({
|
cors({
|
||||||
origin: domain,
|
origin: domain,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
app.use(async (ctx, next) => {
|
app.use(async (ctx, next) => {
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
"description": "一个今日热榜",
|
"description": "一个今日热榜",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"format": "prettier --write .",
|
||||||
|
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix",
|
||||||
"start": "node index.js",
|
"start": "node index.js",
|
||||||
"dev": "npx nodemon index.js",
|
"dev": "npx nodemon index.js",
|
||||||
"prd": "pm2 start index.js",
|
"prd": "pm2 start index.js",
|
||||||
@ -22,6 +24,9 @@
|
|||||||
"koa-views": "^8.0.0",
|
"koa-views": "^8.0.0",
|
||||||
"koa2-cors": "^2.0.6",
|
"koa2-cors": "^2.0.6",
|
||||||
"node-cache": "^5.1.2",
|
"node-cache": "^5.1.2",
|
||||||
"nodemon": "^2.0.22"
|
"nodemon": "^2.0.22",
|
||||||
|
"eslint": "^8.48.0",
|
||||||
|
"eslint-plugin-vue": "^9.17.0",
|
||||||
|
"prettier": "^3.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1970
pnpm-lock.yaml
1970
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,9 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="zh-CN">
|
<html lang="zh-CN">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title>404 | Linkbook API</title>
|
<title>404 | Linkbook API</title>
|
||||||
<link
|
<link rel="shortcut icon" href="https://img.imsyy.top/logo/imsyy.png" type="image/x-icon" />
|
||||||
rel="shortcut icon"
|
|
||||||
href="https://img.imsyy.top/logo/imsyy.png"
|
|
||||||
type="image/x-icon"
|
|
||||||
/>
|
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
href="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/font-awesome/6.0.0/css/all.min.css"
|
href="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/font-awesome/6.0.0/css/all.min.css"
|
||||||
@ -38,7 +34,9 @@
|
|||||||
background-color: var(--text-color-hover);
|
background-color: var(--text-color-hover);
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
font-family: "PingFang SC", "Open Sans", "Microsoft YaHei", sans-serif;
|
font-family: "PingFang SC", "Open Sans", "Microsoft YaHei", sans-serif;
|
||||||
transition: background-color 0.5s, color 0.5s;
|
transition:
|
||||||
|
background-color 0.5s,
|
||||||
|
color 0.5s;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -149,16 +147,12 @@
|
|||||||
<a href="https://imsyy.top/" target="_blank">無名</a>
|
<a href="https://imsyy.top/" target="_blank">無名</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="icp">
|
<div class="icp">
|
||||||
<a href="https://beian.miit.gov.cn/" target="_blank"
|
<a href="https://beian.miit.gov.cn/" target="_blank">豫ICP备2022018134号-1</a>
|
||||||
>豫ICP备2022018134号-1</a
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
<script>
|
<script>
|
||||||
// 跟随系统主题
|
// 跟随系统主题
|
||||||
const darkModeMediaQuery = window.matchMedia(
|
const darkModeMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
||||||
"(prefers-color-scheme: dark)"
|
|
||||||
);
|
|
||||||
const toggleDarkMode = (darkModeMediaQuery) => {
|
const toggleDarkMode = (darkModeMediaQuery) => {
|
||||||
if (darkModeMediaQuery.matches) {
|
if (darkModeMediaQuery.matches) {
|
||||||
document.documentElement.classList.add("dark-mode");
|
document.documentElement.classList.add("dark-mode");
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="zh-CN">
|
<html lang="zh-CN">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title>DailyHot API</title>
|
<title>DailyHot API</title>
|
||||||
<link
|
<link rel="shortcut icon" href="./favicon.svg" type="image/x-icon" />
|
||||||
rel="shortcut icon"
|
|
||||||
href="./favicon.svg"
|
|
||||||
type="image/x-icon"
|
|
||||||
/>
|
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
href="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/font-awesome/6.0.0/css/all.min.css"
|
href="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/font-awesome/6.0.0/css/all.min.css"
|
||||||
@ -38,7 +34,9 @@
|
|||||||
background-color: var(--text-color-hover);
|
background-color: var(--text-color-hover);
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
font-family: "PingFang SC", "Open Sans", "Microsoft YaHei", sans-serif;
|
font-family: "PingFang SC", "Open Sans", "Microsoft YaHei", sans-serif;
|
||||||
transition: background-color 0.5s, color 0.5s;
|
transition:
|
||||||
|
background-color 0.5s,
|
||||||
|
color 0.5s;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -155,16 +153,12 @@
|
|||||||
<a href="https://imsyy.top/" target="_blank">無名</a>
|
<a href="https://imsyy.top/" target="_blank">無名</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="icp">
|
<div class="icp">
|
||||||
<a href="https://beian.miit.gov.cn/" target="_blank"
|
<a href="https://beian.miit.gov.cn/" target="_blank">豫ICP备2022018134号-1</a>
|
||||||
>豫ICP备2022018134号-1</a
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
<script>
|
<script>
|
||||||
// 跟随系统主题
|
// 跟随系统主题
|
||||||
const darkModeMediaQuery = window.matchMedia(
|
const darkModeMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
||||||
"(prefers-color-scheme: dark)"
|
|
||||||
);
|
|
||||||
const toggleDarkMode = (darkModeMediaQuery) => {
|
const toggleDarkMode = (darkModeMediaQuery) => {
|
||||||
if (darkModeMediaQuery.matches) {
|
if (darkModeMediaQuery.matches) {
|
||||||
document.documentElement.classList.add("dark-mode");
|
document.documentElement.classList.add("dark-mode");
|
||||||
|
@ -20,7 +20,7 @@ const getData = (data) => {
|
|||||||
if (!data) return [];
|
if (!data) return [];
|
||||||
const dataList = [];
|
const dataList = [];
|
||||||
try {
|
try {
|
||||||
const pattern = /<\!--s-data:(.*?)-->/s;
|
const pattern = /<!--s-data:(.*?)-->/s;
|
||||||
const matchResult = data.match(pattern);
|
const matchResult = data.match(pattern);
|
||||||
const jsonObject = JSON.parse(matchResult[1]).cards[0].content;
|
const jsonObject = JSON.parse(matchResult[1]).cards[0].content;
|
||||||
jsonObject.forEach((v) => {
|
jsonObject.forEach((v) => {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const Router = require("koa-router");
|
const Router = require("koa-router");
|
||||||
const calendarRouter = new Router();
|
const calendarRouter = new Router();
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
const { get, set, del } = require("../utils/cacheData");
|
const { get, set } = require("../utils/cacheData");
|
||||||
|
|
||||||
// 缓存键名
|
// 缓存键名
|
||||||
const cacheKey = "calendarData";
|
const cacheKey = "calendarData";
|
||||||
@ -96,7 +96,7 @@ calendarRouter.get("/calendar/date", async (ctx) => {
|
|||||||
}
|
}
|
||||||
// 从服务器拉取最新数据
|
// 从服务器拉取最新数据
|
||||||
const response = await axios.get(
|
const response = await axios.get(
|
||||||
`https://baike.baidu.com/cms/home/eventsOnHistory/${month}.json`
|
`https://baike.baidu.com/cms/home/eventsOnHistory/${month}.json`,
|
||||||
);
|
);
|
||||||
const newData = getData(response.data[month][month + day]);
|
const newData = getData(response.data[month][month + day]);
|
||||||
updateTime = new Date().toISOString();
|
updateTime = new Date().toISOString();
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* @author: MyFaith
|
||||||
|
* @date: 2023-09-06
|
||||||
|
* @customEditors: imsyy
|
||||||
|
* @lastEditTime: 2023-09-06
|
||||||
|
*/
|
||||||
|
|
||||||
const Router = require("koa-router");
|
const Router = require("koa-router");
|
||||||
const doubanNewRouter = new Router();
|
const doubanNewRouter = new Router();
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
@ -8,7 +15,7 @@ const { get, set, del } = require("../utils/cacheData");
|
|||||||
const routerInfo = {
|
const routerInfo = {
|
||||||
name: "douban",
|
name: "douban",
|
||||||
title: "豆瓣",
|
title: "豆瓣",
|
||||||
subtitle: "新片榜"
|
subtitle: "新片榜",
|
||||||
};
|
};
|
||||||
|
|
||||||
// 缓存键名
|
// 缓存键名
|
||||||
@ -20,7 +27,8 @@ let updateTime = new Date().toISOString();
|
|||||||
// 调用路径
|
// 调用路径
|
||||||
const url = "https://movie.douban.com/chart/";
|
const url = "https://movie.douban.com/chart/";
|
||||||
const headers = {
|
const headers = {
|
||||||
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1"
|
"User-Agent":
|
||||||
|
"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1",
|
||||||
};
|
};
|
||||||
|
|
||||||
// 豆瓣新片榜单特殊处理 - 标题
|
// 豆瓣新片榜单特殊处理 - 标题
|
||||||
@ -45,7 +53,7 @@ const getData = (data) => {
|
|||||||
comments: $(item).find("span.pl").text().match(/\d+/)[0] ?? "",
|
comments: $(item).find("span.pl").text().match(/\d+/)[0] ?? "",
|
||||||
pic: $(item).find("img").attr("src") ?? "",
|
pic: $(item).find("img").attr("src") ?? "",
|
||||||
url: $(item).find("a").attr("href") ?? "",
|
url: $(item).find("a").attr("href") ?? "",
|
||||||
mobileUrl: `https://m.douban.com/movie/subject/${id}`
|
mobileUrl: `https://m.douban.com/movie/subject/${id}`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return dataList;
|
return dataList;
|
||||||
@ -73,7 +81,7 @@ doubanNewRouter.get("/douban_new", async (ctx) => {
|
|||||||
ctx.body = {
|
ctx.body = {
|
||||||
code: 500,
|
code: 500,
|
||||||
...routerInfo,
|
...routerInfo,
|
||||||
message: "获取失败"
|
message: "获取失败",
|
||||||
};
|
};
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -87,14 +95,14 @@ doubanNewRouter.get("/douban_new", async (ctx) => {
|
|||||||
from,
|
from,
|
||||||
total: data.length,
|
total: data.length,
|
||||||
updateTime,
|
updateTime,
|
||||||
data
|
data,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
code: 500,
|
code: 500,
|
||||||
...routerInfo,
|
...routerInfo,
|
||||||
message: "获取失败"
|
message: "获取失败",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -116,7 +124,7 @@ doubanNewRouter.get("/douban_new/new", async (ctx) => {
|
|||||||
...routerInfo,
|
...routerInfo,
|
||||||
updateTime,
|
updateTime,
|
||||||
total: newData.length,
|
total: newData.length,
|
||||||
data: newData
|
data: newData,
|
||||||
};
|
};
|
||||||
|
|
||||||
// 删除旧数据
|
// 删除旧数据
|
||||||
@ -134,14 +142,14 @@ doubanNewRouter.get("/douban_new/new", async (ctx) => {
|
|||||||
...routerInfo,
|
...routerInfo,
|
||||||
total: cachedData.length,
|
total: cachedData.length,
|
||||||
updateTime,
|
updateTime,
|
||||||
data: cachedData
|
data: cachedData,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// 如果缓存中也没有数据,则返回错误信息
|
// 如果缓存中也没有数据,则返回错误信息
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
code: 500,
|
code: 500,
|
||||||
...routerInfo,
|
...routerInfo,
|
||||||
message: "获取失败"
|
message: "获取失败",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,7 @@ const url =
|
|||||||
"https://www.douyin.com/aweme/v1/web/hot/search/list/?device_platform=webapp&aid=6383&channel=channel_pc_web&detail_list=1&round_trip_time=50";
|
"https://www.douyin.com/aweme/v1/web/hot/search/list/?device_platform=webapp&aid=6383&channel=channel_pc_web&detail_list=1&round_trip_time=50";
|
||||||
|
|
||||||
// Token 获取路径
|
// Token 获取路径
|
||||||
const cookisUrl =
|
const cookisUrl = "https://www.douyin.com/passport/general/login_guiding_strategy/?aid=6383";
|
||||||
"https://www.douyin.com/passport/general/login_guiding_strategy/?aid=6383";
|
|
||||||
|
|
||||||
// 数据处理
|
// 数据处理
|
||||||
const getData = (data) => {
|
const getData = (data) => {
|
||||||
@ -37,9 +36,7 @@ const getData = (data) => {
|
|||||||
pic: `${v.word_cover.url_list[0]}`,
|
pic: `${v.word_cover.url_list[0]}`,
|
||||||
hot: Number(v.hot_value),
|
hot: Number(v.hot_value),
|
||||||
url: `https://www.douyin.com/hot/${encodeURIComponent(v.sentence_id)}`,
|
url: `https://www.douyin.com/hot/${encodeURIComponent(v.sentence_id)}`,
|
||||||
mobileUrl: `https://www.douyin.com/hot/${encodeURIComponent(
|
mobileUrl: `https://www.douyin.com/hot/${encodeURIComponent(v.sentence_id)}`,
|
||||||
v.sentence_id
|
|
||||||
)}`,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return dataList;
|
return dataList;
|
||||||
|
@ -46,9 +46,7 @@ const getData = (data) => {
|
|||||||
pic: `${v.word_cover.url_list[0]}`,
|
pic: `${v.word_cover.url_list[0]}`,
|
||||||
hot: Number(v.hot_value),
|
hot: Number(v.hot_value),
|
||||||
url: `https://www.douyin.com/hot/${encodeURIComponent(v.sentence_id)}`,
|
url: `https://www.douyin.com/hot/${encodeURIComponent(v.sentence_id)}`,
|
||||||
mobileUrl: `https://www.douyin.com/hot/${encodeURIComponent(
|
mobileUrl: `https://www.douyin.com/hot/${encodeURIComponent(v.sentence_id)}`,
|
||||||
v.sentence_id
|
|
||||||
)}`,
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -129,7 +129,7 @@ itHomeRouter.get("/ithome/new", async (ctx) => {
|
|||||||
...routerInfo,
|
...routerInfo,
|
||||||
updateTime,
|
updateTime,
|
||||||
total: newData.length,
|
total: newData.length,
|
||||||
data: newData
|
data: newData,
|
||||||
};
|
};
|
||||||
|
|
||||||
// 删除旧数据
|
// 删除旧数据
|
||||||
@ -147,7 +147,7 @@ itHomeRouter.get("/ithome/new", async (ctx) => {
|
|||||||
...routerInfo,
|
...routerInfo,
|
||||||
total: cachedData.length,
|
total: cachedData.length,
|
||||||
updateTime,
|
updateTime,
|
||||||
data: cachedData
|
data: cachedData,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// 如果缓存中也没有数据,则返回错误信息
|
// 如果缓存中也没有数据,则返回错误信息
|
||||||
|
@ -17,8 +17,7 @@ const cacheKey = "juejinData";
|
|||||||
let updateTime = new Date().toISOString();
|
let updateTime = new Date().toISOString();
|
||||||
|
|
||||||
// 调用路径
|
// 调用路径
|
||||||
const url =
|
const url = "https://api.juejin.cn/content_api/v1/content/article_rank?category_id=1&type=hot";
|
||||||
"https://api.juejin.cn/content_api/v1/content/article_rank?category_id=1&type=hot";
|
|
||||||
|
|
||||||
// 数据处理
|
// 数据处理
|
||||||
const getData = (data) => {
|
const getData = (data) => {
|
||||||
|
@ -29,7 +29,7 @@ const url = "https://www.kuaishou.com/?isHome=1";
|
|||||||
// Unicode 解码
|
// Unicode 解码
|
||||||
const decodedString = (encodedString) => {
|
const decodedString = (encodedString) => {
|
||||||
return encodedString.replace(/\\u([\d\w]{4})/gi, (match, grp) =>
|
return encodedString.replace(/\\u([\d\w]{4})/gi, (match, grp) =>
|
||||||
String.fromCharCode(parseInt(grp, 16))
|
String.fromCharCode(parseInt(grp, 16)),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -44,8 +44,7 @@ const getData = (data) => {
|
|||||||
const jsonObject = JSON.parse(matchResult[1])["defaultClient"];
|
const jsonObject = JSON.parse(matchResult[1])["defaultClient"];
|
||||||
|
|
||||||
// 获取所有分类
|
// 获取所有分类
|
||||||
const allItems =
|
const allItems = jsonObject['$ROOT_QUERY.visionHotRank({"page":"home"})']["items"];
|
||||||
jsonObject['$ROOT_QUERY.visionHotRank({"page":"home"})']["items"];
|
|
||||||
// 遍历所有分类
|
// 遍历所有分类
|
||||||
allItems.forEach((v) => {
|
allItems.forEach((v) => {
|
||||||
// 基础数据
|
// 基础数据
|
||||||
|
@ -34,12 +34,8 @@ const getData = (data) => {
|
|||||||
desc: v.sAuthor,
|
desc: v.sAuthor,
|
||||||
pic: `https:${v.sIMG}`,
|
pic: `https:${v.sIMG}`,
|
||||||
hot: Number(v.iTotalPlay),
|
hot: Number(v.iTotalPlay),
|
||||||
url: `https://lol.qq.com/news/detail.shtml?docid=${encodeURIComponent(
|
url: `https://lol.qq.com/news/detail.shtml?docid=${encodeURIComponent(v.iDocID)}`,
|
||||||
v.iDocID
|
mobileUrl: `https://lol.qq.com/news/detail.shtml?docid=${encodeURIComponent(v.iDocID)}`,
|
||||||
)}`,
|
|
||||||
mobileUrl: `https://lol.qq.com/news/detail.shtml?docid=${encodeURIComponent(
|
|
||||||
v.iDocID
|
|
||||||
)}`,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return dataList;
|
return dataList;
|
||||||
|
@ -30,11 +30,9 @@ const getData = (data) => {
|
|||||||
title: v.word,
|
title: v.word,
|
||||||
desc: key,
|
desc: key,
|
||||||
hot: v.raw_hot,
|
hot: v.raw_hot,
|
||||||
url: `https://s.weibo.com/weibo?q=${encodeURIComponent(
|
url: `https://s.weibo.com/weibo?q=${encodeURIComponent(key)}&t=31&band_rank=1&Refer=top`,
|
||||||
key
|
|
||||||
)}&t=31&band_rank=1&Refer=top`,
|
|
||||||
mobileUrl: `https://s.weibo.com/weibo?q=${encodeURIComponent(
|
mobileUrl: `https://s.weibo.com/weibo?q=${encodeURIComponent(
|
||||||
key
|
key,
|
||||||
)}&t=31&band_rank=1&Refer=top`,
|
)}&t=31&band_rank=1&Refer=top`,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -33,9 +33,7 @@ const getData = (data) => {
|
|||||||
hot: v.readingCount,
|
hot: v.readingCount,
|
||||||
author: book.author,
|
author: book.author,
|
||||||
url: `https://weread.qq.com/web/bookDetail/${getWereadID(book.bookId)}`,
|
url: `https://weread.qq.com/web/bookDetail/${getWereadID(book.bookId)}`,
|
||||||
mobileUrl: `https://weread.qq.com/web/bookDetail/${getWereadID(
|
mobileUrl: `https://weread.qq.com/web/bookDetail/${getWereadID(book.bookId)}`,
|
||||||
book.bookId
|
|
||||||
)}`,
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,6 @@ const Router = require("koa-router");
|
|||||||
const zhihuRouter = new Router();
|
const zhihuRouter = new Router();
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
const { get, set, del } = require("../utils/cacheData");
|
const { get, set, del } = require("../utils/cacheData");
|
||||||
const router = require(".");
|
|
||||||
|
|
||||||
// 接口信息
|
// 接口信息
|
||||||
const routerInfo = {
|
const routerInfo = {
|
||||||
@ -28,8 +27,7 @@ const getData = (data) => {
|
|||||||
if (!data) return [];
|
if (!data) return [];
|
||||||
const dataList = [];
|
const dataList = [];
|
||||||
try {
|
try {
|
||||||
const pattern =
|
const pattern = /<script id="js-initialData" type="text\/json">(.*?)<\/script>/;
|
||||||
/<script id="js-initialData" type="text\/json">(.*?)<\/script>/;
|
|
||||||
const matchResult = data.match(pattern);
|
const matchResult = data.match(pattern);
|
||||||
const jsonObject = JSON.parse(matchResult[1]).initialState.topstory.hotList;
|
const jsonObject = JSON.parse(matchResult[1]).initialState.topstory.hotList;
|
||||||
jsonObject.forEach((v) => {
|
jsonObject.forEach((v) => {
|
||||||
|
@ -47,8 +47,7 @@ const getWereadID = (bookId) => {
|
|||||||
const subLength = sub.length.toString(16);
|
const subLength = sub.length.toString(16);
|
||||||
|
|
||||||
// 如果长度只有一位数,则在前面添加0
|
// 如果长度只有一位数,则在前面添加0
|
||||||
const subLengthPadded =
|
const subLengthPadded = subLength.length === 1 ? "0" + subLength : subLength;
|
||||||
subLength.length === 1 ? "0" + subLength : subLength;
|
|
||||||
|
|
||||||
// 将长度和子字符串添加到初始值中
|
// 将长度和子字符串添加到初始值中
|
||||||
strSub += subLengthPadded + sub;
|
strSub += subLengthPadded + sub;
|
||||||
|
Loading…
Reference in New Issue
Block a user