mirror of
https://github.com/imsyy/DailyHotApi.git
synced 2026-01-12 13:14:55 +08:00
Merge branch 'master' of github.com:imsyy/DailyHotApi
This commit is contained in:
@@ -3,20 +3,19 @@ import type { RouterType } from "../router.types.js";
|
||||
import { get } from "../utils/getData.js";
|
||||
import getBiliWbi from "../utils/getToken/bilibili.js";
|
||||
import { getTime } from "../utils/getTime.js";
|
||||
|
||||
import logger from "../utils/logger.js";
|
||||
const typeMap: Record<string, string> = {
|
||||
"0": "全站",
|
||||
"1": "动画",
|
||||
"3": "音乐",
|
||||
"4": "游戏",
|
||||
"5": "娱乐",
|
||||
"36": "科技",
|
||||
"188": "科技",
|
||||
"119": "鬼畜",
|
||||
"129": "舞蹈",
|
||||
"155": "时尚",
|
||||
"160": "生活",
|
||||
"168": "国创相关",
|
||||
"188": "数码",
|
||||
"181": "影视",
|
||||
};
|
||||
|
||||
@@ -44,18 +43,30 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
||||
const getList = async (options: Options, noCache: boolean): Promise<RouterResType> => {
|
||||
const { type } = options;
|
||||
const wbiData = await getBiliWbi();
|
||||
const url = `https://api.bilibili.com/x/web-interface/ranking/v2?tid=${type}&type=all&${wbiData}`;
|
||||
const url = `https://api.bilibili.com/x/web-interface/ranking/v2?rid=${type}&type=all&${wbiData}`;
|
||||
const result = await get({
|
||||
url,
|
||||
headers: {
|
||||
Referer: `https://www.bilibili.com/ranking/all`,
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36",
|
||||
'Referer': 'https://www.bilibili.com/ranking/all',
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Sec-Ch-Ua': '"Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123"',
|
||||
'Sec-Ch-Ua-Mobile': '?0',
|
||||
'Sec-Ch-Ua-Platform': '"Windows"',
|
||||
'Sec-Fetch-Dest': 'document',
|
||||
'Sec-Fetch-Mode': 'navigate',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'Sec-Fetch-User': '?1',
|
||||
'Upgrade-Insecure-Requests': '1',
|
||||
},
|
||||
noCache,
|
||||
noCache: false,
|
||||
});
|
||||
|
||||
// 是否触发风控
|
||||
if (result.data?.data?.list?.length > 0) {
|
||||
logger.info('bilibili 新接口')
|
||||
const list = result.data.data.list;
|
||||
return {
|
||||
fromCache: result.fromCache,
|
||||
@@ -75,7 +86,8 @@ const getList = async (options: Options, noCache: boolean): Promise<RouterResTyp
|
||||
}
|
||||
// 采用备用接口
|
||||
else {
|
||||
const url = `https://api.bilibili.com/x/web-interface/ranking?jsonp=jsonp?rid=${type}&type=1&callback=__jp0`;
|
||||
logger.info('bilibili 备用接口')
|
||||
const url = `https://api.bilibili.com/x/web-interface/ranking?jsonp=jsonp?rid=${type}&type=all&callback=__jp0`;
|
||||
const result = await get({
|
||||
url,
|
||||
headers: {
|
||||
|
||||
206
src/routes/github.ts
Normal file
206
src/routes/github.ts
Normal file
@@ -0,0 +1,206 @@
|
||||
// getTrending.ts
|
||||
import fetch from "node-fetch";
|
||||
import * as cheerio from "cheerio";
|
||||
import { ListContext } from "../types";
|
||||
import logger from "../utils/logger.js";
|
||||
import { getCache, setCache } from "../utils/cache.js";
|
||||
|
||||
/**
|
||||
* 定义 Trending 仓库信息的类型
|
||||
*/
|
||||
type RepoInfo = {
|
||||
owner: string; // 仓库所属者
|
||||
repo: string; // 仓库名称
|
||||
url: string; // 仓库链接
|
||||
description: string; // 仓库描述
|
||||
language: string; // 编程语言
|
||||
stars: string; // Stars (由于可能包含逗号或者其他符号,这里先用 string 存;实际可自行转 number)
|
||||
forks: string; // Forks
|
||||
todayStars?: string | number; // 今日 Star
|
||||
};
|
||||
|
||||
type TrendingRepoInfo = {
|
||||
data: RepoInfo[];
|
||||
updateTime: string;
|
||||
fromCache: boolean;
|
||||
};
|
||||
|
||||
type TrendingType = "daily" | "weekly" | "monthly";
|
||||
|
||||
const typeMap: Record<TrendingType, string> = {
|
||||
daily: "日榜",
|
||||
weekly: "周榜",
|
||||
monthly: "月榜",
|
||||
};
|
||||
|
||||
function isTrendingType(value: string): value is TrendingType {
|
||||
return ["daily", "weekly", "monthly"].includes(value as TrendingType);
|
||||
}
|
||||
|
||||
export const handleRoute = async (c: ListContext) => {
|
||||
const typeParam = c.req.query("type") || "daily";
|
||||
const type = isTrendingType(typeParam) ? typeParam : "daily";
|
||||
|
||||
const listData = await getTrendingRepos(type);
|
||||
|
||||
const routeData = {
|
||||
name: "github",
|
||||
title: "github 趋势",
|
||||
type: typeMap[type],
|
||||
params: {
|
||||
type: {
|
||||
name: '排行榜分区',
|
||||
type: typeMap,
|
||||
},
|
||||
},
|
||||
link: `https://github.com/trending?since=${type}`,
|
||||
total: listData?.data?.length || 0,
|
||||
...{
|
||||
...listData,
|
||||
data: listData?.data?.map((v, index)=>{
|
||||
return {
|
||||
id:index,
|
||||
title: v.repo,
|
||||
desc: v.description,
|
||||
hot: v.stars,
|
||||
...v
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
return routeData;
|
||||
};
|
||||
|
||||
/**
|
||||
* 爬取 GitHub Trending 列表
|
||||
* @param since 可选参数: 'daily' | 'weekly' | 'monthly',默认值为 'daily'
|
||||
* @returns Promise<RepoInfo[]> 返回包含热门项目信息的数组
|
||||
*/
|
||||
export async function getTrendingRepos(
|
||||
type: TrendingType | string = "daily",
|
||||
ttl = 60 * 60 * 24,
|
||||
): Promise<TrendingRepoInfo> {
|
||||
const url = `https://github.com/trending?since=${type}`;
|
||||
// 先从缓存中取
|
||||
const cachedData = await getCache(url);
|
||||
if (cachedData) {
|
||||
logger.info("💾 [CHCHE] The request is cached");
|
||||
return {
|
||||
fromCache: true,
|
||||
updateTime: cachedData.updateTime,
|
||||
data: (cachedData?.data as RepoInfo[]) || [],
|
||||
};
|
||||
}
|
||||
logger.info(`🌐 [GET] ${url}`);
|
||||
|
||||
// 更新请求头
|
||||
const headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
|
||||
'Accept-Language': 'en-US,en;q=0.5',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Connection': 'keep-alive',
|
||||
'Upgrade-Insecure-Requests': '1',
|
||||
'Sec-Fetch-Dest': 'document',
|
||||
'Sec-Fetch-Mode': 'navigate',
|
||||
'Sec-Fetch-Site': 'none',
|
||||
'Sec-Fetch-User': '?1',
|
||||
'Cache-Control': 'max-age=0',
|
||||
};
|
||||
|
||||
// 添加重试逻辑
|
||||
const maxRetries = 3;
|
||||
let lastError;
|
||||
|
||||
for (let i = 0; i < maxRetries; i++) {
|
||||
try {
|
||||
// 设置超时时间为 20 秒
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 20000);
|
||||
|
||||
const response = await fetch(url, {
|
||||
headers,
|
||||
signal: controller.signal
|
||||
});
|
||||
clearTimeout(timeout);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
const html = await response.text();
|
||||
// 1. 加载 HTML
|
||||
const $ = cheerio.load(html);
|
||||
// 2. 存储结果的数组
|
||||
const results: RepoInfo[] = [];
|
||||
// 3. 遍历每个 article.Box-row
|
||||
$("article.Box-row").each((_, el) => {
|
||||
const $el = $(el);
|
||||
// 仓库标题和链接 (在 <h2> > <a> 里)
|
||||
const $repoAnchor = $el.find("h2 a");
|
||||
// 可能出现 "owner / repo" 这种文本
|
||||
// eg: "owner / repo"
|
||||
const fullNameText = $repoAnchor
|
||||
.text()
|
||||
.trim()
|
||||
// 可能有多余空格,可以再做一次 split
|
||||
// "owner / repo" => ["owner", "repo"]
|
||||
.replace(/\r?\n/g, "") // 去掉换行
|
||||
.replace(/\s+/g, " ") // 多空格处理
|
||||
.split("/")
|
||||
.map((s) => s.trim());
|
||||
|
||||
const owner = fullNameText[0] || "";
|
||||
const repoName = fullNameText[1] || "";
|
||||
|
||||
// href 即仓库链接
|
||||
const repoUrl = "https://github.com" + $repoAnchor.attr("href");
|
||||
|
||||
// 仓库描述 (<p class="col-9 color-fg-muted ...">)
|
||||
const description = $el.find("p.col-9.color-fg-muted").text().trim();
|
||||
|
||||
// 语言 (<span itemprop="programmingLanguage">)
|
||||
const language = $el.find('[itemprop="programmingLanguage"]').text().trim();
|
||||
|
||||
const starsText = $el.find('a[href$="/stargazers"]').text().trim();
|
||||
|
||||
const forksText = $el.find(`a[href$="/forks"]`).text().trim();
|
||||
|
||||
// 整合
|
||||
results.push({
|
||||
owner,
|
||||
repo: repoName,
|
||||
url: repoUrl || "",
|
||||
description,
|
||||
language,
|
||||
stars: starsText,
|
||||
forks: forksText,
|
||||
});
|
||||
});
|
||||
|
||||
const updateTime = new Date().toISOString();
|
||||
const data = results;
|
||||
|
||||
await setCache(url, { data, updateTime }, ttl);
|
||||
// 返回数据
|
||||
logger.info(`✅ [${response?.status}] 请求成功!`);
|
||||
return { fromCache: false, updateTime, data };
|
||||
} catch (error: Error | unknown) {
|
||||
lastError = error;
|
||||
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
||||
logger.error(`❌ [ERROR] 第 ${i + 1} 请求失败: ${errorMessage}`);
|
||||
|
||||
// 如果是最后一次重试,则抛出错误
|
||||
if (i === maxRetries - 1) {
|
||||
logger.error("❌ [ERROR] 所有尝试请求失败!");
|
||||
throw lastError;
|
||||
}
|
||||
|
||||
// 等待一段时间后重试 (1秒、2秒、4秒...)
|
||||
await new Promise(resolve => setTimeout(resolve, Math.pow(2, i) * 1000));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error("请求失败!");
|
||||
}
|
||||
63
src/routes/hackernews.ts
Normal file
63
src/routes/hackernews.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import type { RouterData } from "../types.js";
|
||||
import { get } from "../utils/getData.js";
|
||||
import { load } from "cheerio";
|
||||
import type { RouterType } from "../router.types.js";
|
||||
|
||||
export const handleRoute = async (_: undefined, noCache: boolean) => {
|
||||
const listData = await getList(noCache);
|
||||
const routeData: RouterData = {
|
||||
name: "hackernews",
|
||||
title: "Hacker News",
|
||||
type: "Popular",
|
||||
description: "News about hacking and startups",
|
||||
link: "https://news.ycombinator.com/",
|
||||
total: listData.data?.length || 0,
|
||||
...listData,
|
||||
};
|
||||
return routeData;
|
||||
};
|
||||
|
||||
const getList = async (noCache: boolean) => {
|
||||
const baseUrl = "https://news.ycombinator.com";
|
||||
const result = await get({
|
||||
url: baseUrl,
|
||||
noCache,
|
||||
headers: {
|
||||
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
const $ = load(result.data);
|
||||
const stories: RouterType["hackernews"][] = [];
|
||||
|
||||
$(".athing").each((_, el) => {
|
||||
const item = $(el);
|
||||
const id = item.attr("id") || "";
|
||||
const title = item.find(".titleline a").first().text().trim();
|
||||
const url = item.find(".titleline a").first().attr("href");
|
||||
|
||||
// 获取分数并转换为数字
|
||||
const scoreText = $(`#score_${id}`).text().match(/\d+/)?.[0];
|
||||
const hot = scoreText ? parseInt(scoreText, 10) : undefined;
|
||||
|
||||
if (id && title) {
|
||||
stories.push({
|
||||
id,
|
||||
title,
|
||||
hot,
|
||||
timestamp: undefined,
|
||||
url: url || `${baseUrl}/item?id=${id}`,
|
||||
mobileUrl: url || `${baseUrl}/item?id=${id}`,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
...result,
|
||||
data: stories,
|
||||
};
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to parse HackerNews HTML: ${error}`);
|
||||
}
|
||||
};
|
||||
@@ -1,13 +1,55 @@
|
||||
import type { RouterData } from "../types.js";
|
||||
import type { ListContext, RouterData } from "../types.js";
|
||||
import type { RouterType } from "../router.types.js";
|
||||
import { get } from "../utils/getData.js";
|
||||
|
||||
export const handleRoute = async (_: undefined, noCache: boolean) => {
|
||||
const listData = await getList(noCache);
|
||||
|
||||
const headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Cache-Control': 'no-cache',
|
||||
'Connection': 'keep-alive',
|
||||
'Sec-Ch-Ua': '"Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123"',
|
||||
'Sec-Ch-Ua-Mobile': '?0',
|
||||
'Sec-Ch-Ua-Platform': '"Windows"',
|
||||
'Sec-Fetch-Dest': 'document',
|
||||
'Sec-Fetch-Mode': 'navigate',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'Sec-Fetch-User': '?1',
|
||||
'Upgrade-Insecure-Requests': '1',
|
||||
}
|
||||
|
||||
const category_url = 'https://api.juejin.cn/tag_api/v1/query_category_briefs'
|
||||
const getCategory = async()=>{
|
||||
const res = await get({
|
||||
url: category_url,
|
||||
headers
|
||||
})
|
||||
const data = res?.data?.data || []
|
||||
const typeObj: Record<string, string> = {}
|
||||
typeObj['1'] = '综合'
|
||||
data.forEach((c: { category_id: string; category_name: string }) => {
|
||||
typeObj[c.category_id] = c.category_name
|
||||
})
|
||||
|
||||
return typeObj
|
||||
}
|
||||
|
||||
export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
||||
const type = c.req.query("type") || 1;
|
||||
const listData = await getList(noCache, type);
|
||||
const typeMaps = await getCategory()
|
||||
const routeData: RouterData = {
|
||||
name: "juejin",
|
||||
title: "稀土掘金",
|
||||
type: "文章榜",
|
||||
params: {
|
||||
type: {
|
||||
name: "排行榜分区",
|
||||
type: typeMaps,
|
||||
},
|
||||
},
|
||||
link: "https://juejin.cn/hot/articles",
|
||||
total: listData.data?.length || 0,
|
||||
...listData,
|
||||
@@ -15,9 +57,9 @@ export const handleRoute = async (_: undefined, noCache: boolean) => {
|
||||
return routeData;
|
||||
};
|
||||
|
||||
const getList = async (noCache: boolean) => {
|
||||
const url = `https://api.juejin.cn/content_api/v1/content/article_rank?category_id=1&type=hot`;
|
||||
const result = await get({ url, noCache });
|
||||
const getList = async (noCache: boolean, type: number | string = 1) => {
|
||||
const url = `https://api.juejin.cn/content_api/v1/content/article_rank?category_id=${type}&type=hot`;
|
||||
const result = await get({ url, noCache, headers });
|
||||
const list = result.data.data;
|
||||
return {
|
||||
...result,
|
||||
|
||||
57
src/routes/linuxdo.ts
Normal file
57
src/routes/linuxdo.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import type { RouterData } from "../types.js";
|
||||
import { get } from "../utils/getData.js";
|
||||
import { getTime } from "../utils/getTime.js";
|
||||
|
||||
interface Topic {
|
||||
id: number;
|
||||
title: string;
|
||||
excerpt: string;
|
||||
last_poster_username: string;
|
||||
created_at: string;
|
||||
views: number;
|
||||
like_count: number;
|
||||
}
|
||||
|
||||
export const handleRoute = async (_: undefined, noCache: boolean) => {
|
||||
const listData = await getList(noCache);
|
||||
const routeData: RouterData = {
|
||||
name: "linuxdo",
|
||||
title: "Linux.do",
|
||||
type: "热门文章",
|
||||
description: "Linux 技术社区热搜",
|
||||
link: "https://linux.do/hot",
|
||||
total: listData.data?.length || 0,
|
||||
...listData,
|
||||
};
|
||||
return routeData;
|
||||
};
|
||||
|
||||
const getList = async (noCache: boolean) => {
|
||||
const url = "https://linux.do/top/weekly.json";
|
||||
const result = await get({
|
||||
url,
|
||||
noCache,
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
}
|
||||
});
|
||||
|
||||
const topics = result.data.topic_list.topics as Topic[];
|
||||
const list = topics.map((topic) => {
|
||||
return {
|
||||
id: topic.id,
|
||||
title: topic.title,
|
||||
desc: topic.excerpt,
|
||||
author: topic.last_poster_username,
|
||||
timestamp: getTime(topic.created_at),
|
||||
url: `https://linux.do/t/${topic.id}`,
|
||||
mobileUrl: `https://linux.do/t/${topic.id}`,
|
||||
hot: topic.views || topic.like_count
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
...result,
|
||||
data: list
|
||||
};
|
||||
};
|
||||
60
src/routes/producthunt.ts
Normal file
60
src/routes/producthunt.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import type { RouterData } from "../types.js";
|
||||
import { get } from "../utils/getData.js";
|
||||
import { load } from "cheerio";
|
||||
import type { RouterType } from "../router.types.js";
|
||||
|
||||
export const handleRoute = async (_: undefined, noCache: boolean) => {
|
||||
const listData = await getList(noCache);
|
||||
const routeData: RouterData = {
|
||||
name: "producthunt",
|
||||
title: "Product Hunt",
|
||||
type: "Today",
|
||||
description: "The best new products, every day",
|
||||
link: "https://www.producthunt.com/",
|
||||
total: listData.data?.length || 0,
|
||||
...listData,
|
||||
};
|
||||
return routeData;
|
||||
};
|
||||
|
||||
const getList = async (noCache: boolean) => {
|
||||
const baseUrl = "https://www.producthunt.com";
|
||||
const result = await get({
|
||||
url: baseUrl,
|
||||
noCache,
|
||||
headers: {
|
||||
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
const $ = load(result.data);
|
||||
const stories: RouterType["producthunt"][] = [];
|
||||
|
||||
$("[data-test=homepage-section-0] [data-test^=post-item]").each((_, el) => {
|
||||
const a = $(el).find("a").first();
|
||||
const path = a.attr("href");
|
||||
const title = $(el).find("a[data-test^=post-name]").text().trim();
|
||||
const id = $(el).attr("data-test")?.replace("post-item-", "");
|
||||
const vote = $(el).find("[data-test=vote-button]").text().trim();
|
||||
|
||||
if (path && id && title) {
|
||||
stories.push({
|
||||
id,
|
||||
title,
|
||||
hot: parseInt(vote) || undefined,
|
||||
timestamp: undefined,
|
||||
url: `${baseUrl}${path}`,
|
||||
mobileUrl: `${baseUrl}${path}`,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
...result,
|
||||
data: stories,
|
||||
};
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to parse Product Hunt HTML: ${error}`);
|
||||
}
|
||||
};
|
||||
@@ -1,15 +1,30 @@
|
||||
import type { RouterData } from "../types.js";
|
||||
import type { ListContext, RouterData } from "../types.js";
|
||||
import type { RouterType } from "../router.types.js";
|
||||
import { get } from "../utils/getData.js";
|
||||
import getWereadID from "../utils/getToken/weread.js";
|
||||
import { getTime } from "../utils/getTime.js";
|
||||
|
||||
export const handleRoute = async (_: undefined, noCache: boolean) => {
|
||||
const listData = await getList(noCache);
|
||||
const typeMap: Record<string, string> = {
|
||||
rising: "飙升榜",
|
||||
hot_search: "热搜榜",
|
||||
newbook: "新书榜",
|
||||
general_novel_rising: "小说榜",
|
||||
all: "总榜",
|
||||
};
|
||||
|
||||
export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
||||
const type = c.req.query("type") || "rising";
|
||||
const listData = await getList(noCache, type);
|
||||
const routeData: RouterData = {
|
||||
name: "weread",
|
||||
title: "微信读书",
|
||||
type: "飙升榜",
|
||||
type: `${typeMap[type]}`,
|
||||
params: {
|
||||
type: {
|
||||
name: "排行榜分区",
|
||||
type: typeMap,
|
||||
},
|
||||
},
|
||||
link: "https://weread.qq.com/",
|
||||
total: listData.data?.length || 0,
|
||||
...listData,
|
||||
@@ -17,8 +32,8 @@ export const handleRoute = async (_: undefined, noCache: boolean) => {
|
||||
return routeData;
|
||||
};
|
||||
|
||||
const getList = async (noCache: boolean) => {
|
||||
const url = `https://weread.qq.com/web/bookListInCategory/rising?rank=1`;
|
||||
const getList = async (noCache: boolean, type='rising') => {
|
||||
const url = `https://weread.qq.com/web/bookListInCategory/${type}?rank=1`;
|
||||
const result = await get({
|
||||
url,
|
||||
noCache,
|
||||
|
||||
@@ -24,6 +24,7 @@ const getList = async (noCache: boolean) => {
|
||||
...result,
|
||||
data: list.map((v: RouterType["zhihu"]) => {
|
||||
const data = v.target;
|
||||
const questionId = data.url.split("/").pop();
|
||||
return {
|
||||
id: data.id,
|
||||
title: data.title,
|
||||
@@ -31,8 +32,8 @@ const getList = async (noCache: boolean) => {
|
||||
cover: v.children[0].thumbnail,
|
||||
timestamp: getTime(data.created),
|
||||
hot: parseFloat(v.detail_text.split(" ")[0]) * 10000,
|
||||
url: `https://www.zhihu.com/question/${data.id}`,
|
||||
mobileUrl: `https://www.zhihu.com/question/${data.id}`,
|
||||
url: `https://www.zhihu.com/question/${questionId}`,
|
||||
mobileUrl: `https://www.zhihu.com/question/${questionId}`,
|
||||
};
|
||||
}),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user