rsshub
Version:
Make RSS Great Again!
58 lines (56 loc) • 1.88 kB
JavaScript
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 { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { n as parseArticle, t as baseUrl } from "./utils-Blx5-Wjc.mjs";
import { load } from "cheerio";
//#region lib/routes/woshipm/user-article.ts
const route = {
path: "/user_article/:id",
categories: ["new-media"],
example: "/woshipm/user_article/324696",
parameters: { id: "用户 id" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["woshipm.com/u/:id"] }],
name: "用户文章",
maintainers: ["LogicJake"],
handler
};
async function handler(ctx) {
const id = ctx.req.param("id");
const limit = ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 12;
const link = `${baseUrl}/u/${id}`;
const $ = load(await got_default(link).then((res) => res.data));
const name = $(".author--meta .name").text();
const list = $(".post--card").slice(0, limit).toArray().map((item) => {
item = $(item);
const postCardTitle = item.find("h2.post--card__title a");
return {
title: postCardTitle.attr("title"),
link: postCardTitle.attr("href"),
pubDate: parseDate(item.find("time").text(), "YYYY-MM-DD")
};
});
const items = await Promise.all(list.map((item) => parseArticle(item, cache_default.tryGet)));
return {
title: `${name}的文章-人人都是产品经理`,
description: $(".author--meta .description").text(),
image: $(".author--meta .avatar").attr("src").split("!")[0],
link,
item: items
};
}
//#endregion
export { route };