UNPKG

rsshub

Version:
58 lines (56 loc) 1.75 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as auth_default } from "./auth-Cby6FaL3.mjs"; //#region lib/routes/zhihu/xhu/posts.ts const route = { path: "/xhu/people/posts/:hexId", categories: ["social-media"], example: "/zhihu/xhu/people/posts/246e6cf44e94cefbf4b959cb5042bc91", parameters: { hexId: "用户的 16 进制 id,获取方式同 [xhu - 用户动态](#zhi-hu-xhu-yong-hu-dong-tai)" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "xhu - 用户文章", maintainers: ["JimenezLi"], handler }; async function handler(ctx) { const xhuCookie = await auth_default.getCookie(); const hexId = ctx.req.param("hexId"); const link = `https://www.zhihu.com/people/${hexId}/posts`; const data = (await got_default({ method: "get", url: `https://api.zhihuvvv.workers.dev/people/${hexId}/articles?limit=20&offset=0`, headers: { Referer: "https://api.zhihuvvv.workers.dev", Cookie: xhuCookie } })).data.data; return { title: `${data[0].author.name} 的知乎文章`, link, image: data[0].author.avatar_url, description: data[0].author.headline, item: data.map((item) => ({ title: item.title, description: item.excerpt, pubDate: parseDate(item.created * 1e3), link: `https://zhuanlan.zhihu.com/p/${item.id}`, author: item.author.name })) }; } //#endregion export { route };