rsshub
Version:
Make RSS Great Again!
42 lines (40 loc) • 1.62 kB
JavaScript
import { t as cache_default } from "./cache-BkqOokyU.mjs";
import { t as got_default } from "./got-BTowW50G.mjs";
import { t as getRssItem } from "./utils-BLQQjdJk.mjs";
//#region lib/routes/lifeweek/tag.ts
const rootApiUrl = "https://www.lifeweek.com.cn/api/userWebFollow/getFollowTagContentList?type=4&sort=2&tagId";
const rootUrl = "https://www.lifeweek.com.cn/articleList";
const articleRootUrl = "https://www.lifeweek.com.cn/article";
const route = {
path: "/tag/:id",
categories: ["traditional-media"],
example: "/lifeweek/tag/122",
parameters: { id: "标签 ID" },
description: `提取文章全文,获得更好的阅读体验。支持所有标签,标签名称见 [全部标签](https://www.lifeweek.com.cn/classify?type=1)。例如 [社会调查标签](https://www.lifeweek.com.cn/articleList/122) URL 最后的数字为标签 ID
| 社会调查 | 社会 | 经济 | 理财 | 热点 |
| -------- | ---- | ---- | ---- | ---- |
| 122 | 21 | 73 | 74 | 123 |`,
radar: [{
source: ["lifeweek.com.cn/articleList/:tag"],
target: "/tag/:tag"
}],
name: "标签",
maintainers: ["changren-wcr"],
handler
};
async function handler(ctx) {
const tag = ctx.req.param("id");
const { data } = await got_default(`${rootApiUrl}=${tag}`);
const result = data.model.articleResponseList;
const items = await Promise.all(result.map((item) => {
const articleLink = `${articleRootUrl}/${item.id}`;
return cache_default.tryGet(articleLink, () => getRssItem(item, articleLink));
}));
return {
title: data.model.tagName,
link: `${rootUrl}/${tag}`,
item: items
};
}
//#endregion
export { route };