rsshub
Version:
Make RSS Great Again!
64 lines (62 loc) • 2.34 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 { t as rss_parser_default } from "./rss-parser-Dtop7M8f.mjs";
import { r as fixArticleContent } from "./wechat-mp-Dq_pp853.mjs";
import { load } from "cheerio";
//#region lib/routes/wechat/ce.ts
const UA = "Mozilla/5.0 (X11; Linux x86_64) RSS Reader";
const route = {
path: "/ce/:id",
categories: ["new-media"],
example: "/wechat/ce/595a5b14d7164e53908f1606",
parameters: { id: "公众号 id,在 [CareerEngine](https://search.careerengine.us/) 搜索公众号,通过 URL 中找到对应的公众号 id" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["cimidata.com/a/:id"] }],
name: "公众号(CareerEngine 来源)",
maintainers: ["HenryQW"],
handler
};
async function handler(ctx) {
const id = ctx.req.param("id");
const feed = await rss_parser_default.parseString(await got_default.get(`https://posts.careerengine.us/author/${id}/rss`, { headers: { "User-Agent": UA } }).then((_) => _.data));
const items = await Promise.all(feed.items.splice(0, 10).map((item) => {
item.link = item.link.replace(/^http:\/\//, "https://");
return cache_default.tryGet(item.link, async () => {
const $ = load((await got_default.get(item.link, { headers: { "User-Agent": UA } })).data);
const description = fixArticleContent($(".post"));
let pubDate = item.pubDate;
if (!pubDate || pubDate === "Invalid Date") {
pubDate = parseDate($(".post-date").text().replaceAll(/\s+|发表/g, ""), "YYYY年MM月DD日");
pubDate = /* @__PURE__ */ new Date(pubDate.getTime() - pubDate.getTimezoneOffset() * 60 * 1e3);
}
return {
title: item.title,
description,
pubDate,
link: item.link
};
});
}));
return {
title: `微信公众号 - ${feed.title}`,
link: `https://posts.careerengine.us/author/${id}/posts`,
description: feed.description,
item: items
};
}
//#endregion
export { route };