mirror of
https://github.com/imsyy/DailyHotApi.git
synced 2026-01-12 13:14:55 +08:00
✨ feat: 新增 酷安热榜
This commit is contained in:
@@ -53,7 +53,7 @@
|
|||||||
| 36 氪 | 热榜 | 36kr | 🟢 |
|
| 36 氪 | 热榜 | 36kr | 🟢 |
|
||||||
| 51CTO | 推荐榜 | 51cto | 🟢 |
|
| 51CTO | 推荐榜 | 51cto | 🟢 |
|
||||||
| CSDN | 排行榜 | csdn | 🟢 |
|
| CSDN | 排行榜 | csdn | 🟢 |
|
||||||
| NodeSeek | 最新动态 | nodeseek | 🟢 |
|
| NodeSeek | 最新动态 | nodeseek | 🟠 |
|
||||||
| 稀土掘金 | 热榜 | juejin | 🟢 |
|
| 稀土掘金 | 热榜 | juejin | 🟢 |
|
||||||
| 腾讯新闻 | 热点榜 | qq-news | 🟢 |
|
| 腾讯新闻 | 热点榜 | qq-news | 🟢 |
|
||||||
| 新浪网 | 热榜 | sina | 🟢 |
|
| 新浪网 | 热榜 | sina | 🟢 |
|
||||||
@@ -62,6 +62,7 @@
|
|||||||
| 吾爱破解 | 榜单 | 52pojie | ❌ |
|
| 吾爱破解 | 榜单 | 52pojie | ❌ |
|
||||||
| 全球主机交流 | 榜单 | hostloc | ❌ |
|
| 全球主机交流 | 榜单 | hostloc | ❌ |
|
||||||
| 虎嗅 | 24小时 | huxiu | 🟢 |
|
| 虎嗅 | 24小时 | huxiu | 🟢 |
|
||||||
|
| 酷安 | 热榜 | coolapk | 🟢 |
|
||||||
| 虎扑 | 步行街热帖 | hupu | 🟢 |
|
| 虎扑 | 步行街热帖 | hupu | 🟢 |
|
||||||
| 爱范儿 | 快讯 | ifanr | 🟢 |
|
| 爱范儿 | 快讯 | ifanr | 🟢 |
|
||||||
| 英雄联盟 | 更新公告 | lol | 🟢 |
|
| 英雄联盟 | 更新公告 | lol | 🟢 |
|
||||||
@@ -72,8 +73,8 @@
|
|||||||
| NGA | 热帖 | ngabbs | 🟢 |
|
| NGA | 热帖 | ngabbs | 🟢 |
|
||||||
| V2EX | 主题榜 | v2ex | ⚠️ |
|
| V2EX | 主题榜 | v2ex | ⚠️ |
|
||||||
| HelloGitHub | Trending | hellogithub | 🟢 |
|
| HelloGitHub | Trending | hellogithub | 🟢 |
|
||||||
| 中央气象台 | 全国气象预警 | weatheralarm | 🟢 |
|
| 中央气象台 | 全国气象预警 | weatheralarm | 🟠 |
|
||||||
| 中国地震台 | 地震速报 | earthquake | 🟢 |
|
| 中国地震台 | 地震速报 | earthquake | 🟠 |
|
||||||
| 历史上的今天 | 月-日 | history | 🟢 |
|
| 历史上的今天 | 月-日 | history | 🟢 |
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dailyhot-api",
|
"name": "dailyhot-api",
|
||||||
"version": "2.0.5",
|
"version": "2.0.6",
|
||||||
"description": "An Api on Today's Hot list",
|
"description": "An Api on Today's Hot list",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"API",
|
"API",
|
||||||
|
|||||||
10
src/router.types.d.ts
vendored
10
src/router.types.d.ts
vendored
@@ -127,6 +127,7 @@ export type RouterType = {
|
|||||||
cover: string;
|
cover: string;
|
||||||
created_at: number;
|
created_at: number;
|
||||||
view_status: number;
|
view_status: number;
|
||||||
|
images: string[];
|
||||||
};
|
};
|
||||||
user: {
|
user: {
|
||||||
nickname: string;
|
nickname: string;
|
||||||
@@ -305,4 +306,13 @@ export type RouterType = {
|
|||||||
top_num: string;
|
top_num: string;
|
||||||
time: string;
|
time: string;
|
||||||
};
|
};
|
||||||
|
coolapk: {
|
||||||
|
id: number;
|
||||||
|
ttitle: string;
|
||||||
|
shareUrl: string;
|
||||||
|
username:string;
|
||||||
|
tpic: string;
|
||||||
|
message: string;
|
||||||
|
replynum: number;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
45
src/routes/coolapk.ts
Normal file
45
src/routes/coolapk.ts
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import type { RouterData } from "../types.js";
|
||||||
|
import type { RouterType } from "../router.types.js";
|
||||||
|
import { get } from "../utils/getData.js";
|
||||||
|
import { genHeaders } from "../utils/getToken/coolapk.js";
|
||||||
|
|
||||||
|
export const handleRoute = async (_: undefined, noCache: boolean) => {
|
||||||
|
const { fromCache, data, updateTime } = await getList(noCache);
|
||||||
|
const routeData: RouterData = {
|
||||||
|
name: "coolapk",
|
||||||
|
title: "酷安",
|
||||||
|
type: "热榜",
|
||||||
|
link: "https://www.coolapk.com/",
|
||||||
|
total: data?.length || 0,
|
||||||
|
updateTime,
|
||||||
|
fromCache,
|
||||||
|
data,
|
||||||
|
};
|
||||||
|
return routeData;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getList = async (noCache: boolean) => {
|
||||||
|
const url = `https://api.coolapk.com/v6/page/dataList?url=/feed/statList?cacheExpires=300&statType=day&sortField=detailnum&title=今日热门&title=今日热门&subTitle=&page=1`;
|
||||||
|
const result = await get({
|
||||||
|
url,
|
||||||
|
noCache,
|
||||||
|
headers: await genHeaders(),
|
||||||
|
});
|
||||||
|
const list = result.data.data;
|
||||||
|
console.log(list);
|
||||||
|
return {
|
||||||
|
fromCache: result.fromCache,
|
||||||
|
updateTime: result.updateTime,
|
||||||
|
data: list.map((v: RouterType["coolapk"]) => ({
|
||||||
|
id: v.id,
|
||||||
|
title: v.message,
|
||||||
|
cover: v.tpic,
|
||||||
|
author: v.username,
|
||||||
|
desc: v.ttitle,
|
||||||
|
timestamp: null,
|
||||||
|
hot: null,
|
||||||
|
url: v.shareUrl,
|
||||||
|
mobileUrl: v.shareUrl,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -31,7 +31,7 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
|||||||
|
|
||||||
const getList = async (options: Options, noCache: boolean) => {
|
const getList = async (options: Options, noCache: boolean) => {
|
||||||
const { type } = options;
|
const { type } = options;
|
||||||
const url = `https://bbs-api.miyoushe.com/post/wapi/getNewsList?gids=2&page_size=20&type=${type}`;
|
const url = `https://bbs-api-static.miyoushe.com/painter/wapi/getNewsList?client_type=4&gids=2&last_id=&page_size=20&type=${type}`;
|
||||||
const result = await get({ url, noCache });
|
const result = await get({ url, noCache });
|
||||||
const list = result.data.data.list;
|
const list = result.data.data.list;
|
||||||
return {
|
return {
|
||||||
@@ -43,7 +43,7 @@ const getList = async (options: Options, noCache: boolean) => {
|
|||||||
id: data.post_id,
|
id: data.post_id,
|
||||||
title: data.subject,
|
title: data.subject,
|
||||||
desc: data.content,
|
desc: data.content,
|
||||||
cover: data.cover,
|
cover: data.cover || data?.images?.[0],
|
||||||
author: v.user?.nickname || null,
|
author: v.user?.nickname || null,
|
||||||
timestamp: getTime(data.created_at),
|
timestamp: getTime(data.created_at),
|
||||||
hot: data.view_status,
|
hot: data.view_status,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
|||||||
|
|
||||||
const getList = async (options: Options, noCache: boolean) => {
|
const getList = async (options: Options, noCache: boolean) => {
|
||||||
const { type } = options;
|
const { type } = options;
|
||||||
const url = `https://bbs-api.miyoushe.com/post/wapi/getNewsList?gids=1&page_size=20&type=${type}`;
|
const url = `https://bbs-api-static.miyoushe.com/painter/wapi/getNewsList?client_type=4&gids=1&last_id=&page_size=20&type=${type}`;
|
||||||
const result = await get({ url, noCache });
|
const result = await get({ url, noCache });
|
||||||
const list = result.data.data.list;
|
const list = result.data.data.list;
|
||||||
return {
|
return {
|
||||||
@@ -43,7 +43,7 @@ const getList = async (options: Options, noCache: boolean) => {
|
|||||||
id: data.post_id,
|
id: data.post_id,
|
||||||
title: data.subject,
|
title: data.subject,
|
||||||
desc: data.content,
|
desc: data.content,
|
||||||
cover: data.cover,
|
cover: data.cover || data?.images?.[0],
|
||||||
author: v.user?.nickname || null,
|
author: v.user?.nickname || null,
|
||||||
timestamp: getTime(data.created_at),
|
timestamp: getTime(data.created_at),
|
||||||
hot: data.view_status,
|
hot: data.view_status,
|
||||||
|
|||||||
@@ -28,15 +28,12 @@ export const handleRoute = async (_: undefined, noCache: boolean) => {
|
|||||||
const getList = async (noCache: boolean) => {
|
const getList = async (noCache: boolean) => {
|
||||||
const url = `https://rss.nodeseek.com/`;
|
const url = `https://rss.nodeseek.com/`;
|
||||||
const result = await get({ url, noCache });
|
const result = await get({ url, noCache });
|
||||||
|
|
||||||
const rssData = await parseStringPromise(result.data);
|
const rssData = await parseStringPromise(result.data);
|
||||||
|
|
||||||
const list = rssData.rss.channel[0].item;
|
const list = rssData.rss.channel[0].item;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fromCache: result.fromCache,
|
fromCache: result.fromCache,
|
||||||
updateTime: result.updateTime,
|
updateTime: result.updateTime,
|
||||||
data: list.map((v: any) => ({
|
data: list.map((v) => ({
|
||||||
id: v.guid[0]._,
|
id: v.guid[0]._,
|
||||||
title: v.title[0],
|
title: v.title[0],
|
||||||
desc: v.description ? v.description[0] : "",
|
desc: v.description ? v.description[0] : "",
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export const handleRoute = async (c: ListContext, noCache: boolean) => {
|
|||||||
|
|
||||||
const getList = async (options: Options, noCache: boolean) => {
|
const getList = async (options: Options, noCache: boolean) => {
|
||||||
const { type } = options;
|
const { type } = options;
|
||||||
const url = `https://bbs-api.miyoushe.com/post/wapi/getNewsList?gids=6&page_size=20&type=${type}`;
|
const url = `https://bbs-api-static.miyoushe.com/painter/wapi/getNewsList?client_type=4&gids=6&page_size=20&type=${type}`;
|
||||||
const result = await get({ url, noCache });
|
const result = await get({ url, noCache });
|
||||||
const list = result.data.data.list;
|
const list = result.data.data.list;
|
||||||
return {
|
return {
|
||||||
@@ -43,7 +43,7 @@ const getList = async (options: Options, noCache: boolean) => {
|
|||||||
id: data.post_id,
|
id: data.post_id,
|
||||||
title: data.subject,
|
title: data.subject,
|
||||||
desc: data.content,
|
desc: data.content,
|
||||||
cover: data.cover,
|
cover: data.cover || data?.images?.[0],
|
||||||
author: v.user?.nickname || null,
|
author: v.user?.nickname || null,
|
||||||
timestamp: getTime(data.created_at),
|
timestamp: getTime(data.created_at),
|
||||||
hot: data.view_status,
|
hot: data.view_status,
|
||||||
|
|||||||
49
src/utils/getToken/coolapk.ts
Normal file
49
src/utils/getToken/coolapk.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import md5 from "md5";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取随机的DEVICE_ID
|
||||||
|
* @returns DEVICE_ID
|
||||||
|
*/
|
||||||
|
const getRandomDEVICE_ID = () => {
|
||||||
|
const id = [10, 6, 6, 6, 14];
|
||||||
|
return id.map((i) => Math.random().toString(36).substring(2, i)).join("-");
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取APP_TOKEN
|
||||||
|
* @returns APP_TOKEN
|
||||||
|
*/
|
||||||
|
const get_app_token = async () => {
|
||||||
|
const DEVICE_ID = getRandomDEVICE_ID();
|
||||||
|
const now = Math.round(Date.now() / 1000);
|
||||||
|
const hex_now = "0x" + now.toString(16);
|
||||||
|
const md5_now = await md5(now.toString());
|
||||||
|
const s =
|
||||||
|
"token://com.coolapk.market/c67ef5943784d09750dcfbb31020f0ab?" +
|
||||||
|
md5_now +
|
||||||
|
"$" +
|
||||||
|
DEVICE_ID +
|
||||||
|
"&com.coolapk.market";
|
||||||
|
const md5_s = await md5(Buffer.from(s).toString("base64"));
|
||||||
|
const token = md5_s + DEVICE_ID + hex_now;
|
||||||
|
return token;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取请求头
|
||||||
|
* @returns 请求头
|
||||||
|
*/
|
||||||
|
export const genHeaders = async () => {
|
||||||
|
return {
|
||||||
|
"X-Requested-With": "XMLHttpRequest",
|
||||||
|
"X-App-Id": "com.coolapk.market",
|
||||||
|
"X-App-Token": await get_app_token(),
|
||||||
|
"X-Sdk-Int": "29",
|
||||||
|
"X-Sdk-Locale": "zh-CN",
|
||||||
|
"X-App-Version": "11.0",
|
||||||
|
"X-Api-Version": "11",
|
||||||
|
"X-App-Code": "2101202",
|
||||||
|
"User-Agent":
|
||||||
|
"Mozilla/5.0 (Linux; Android 10; Mi 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.5563.15 Mobile Safari/537.36",
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user