UNPKG

rsshub

Version:
41 lines (40 loc) 1.33 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as parseDate } from "./parse-date-CjhZE69i.mjs"; import { t as cache_default } from "./cache-CiDoUSLo.mjs"; import { t as timezone } from "./timezone-DE--ze1V.mjs"; import { load } from "cheerio"; //#region lib/routes/eefocus/article.ts const route = { path: "/rf/article", categories: ["bbs"], example: "/eefocus/rf/article", name: "文章", maintainers: ["nczitzk"], handler }; async function handler() { const rootUrl = "https://rf.eefocus.com/article/"; const $ = load(await rofetch(rootUrl)); const list = $("h3.media-heading").slice(0, 10).toArray().map((item) => { const a = $(item).find("a"); return { title: a.text(), link: new URL(a.attr("href"), "https://rf.eefocus.com/").href }; }); return { title: "RF技术社区 - 文章", link: rootUrl, item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const content = load(await rofetch(item.link)); return { ...item, pubDate: timezone(parseDate(content("div.article-subline-desc").eq(0).text().replace("发布时间:", "")), 8), description: content("div.clearfix.article-content").html(), category: content(".tag-terms a").toArray().map((tag) => content(tag).text()) }; }))) }; } //#endregion export { route };