UNPKG

rsshub

Version:
58 lines (56 loc) 1.96 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import { load } from "cheerio"; //#region lib/routes/elecfans/soft.ts const route = { path: "/soft/:atype", categories: ["programming"], example: "/elecfans/soft/special", parameters: { atype: "需获取资料的类别" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "资料", radar: [{ source: ["www.elecfans.com"] }], maintainers: ["tian051011"], handler: async (ctx) => { const { atype } = ctx.req.param(); const $ = load(await ofetch_default(`https://www.elecfans.com/soft/${atype}/`)); const list = $("#mainContent li").toArray().map((item) => { item = $(item); const a = item.find("a").eq(1); return { title: a.text(), link: String(a.attr("href")) }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const $$1 = load(await ofetch_default(item.link)); item.pubDate = parseDate($$1(".data-info-content2021 .upload-date").eq(1).text()); const userInfoApi = `https://www.elecfans.com/webapi/user/getSoftUserInfo?mid=${$$1("#filed_mid2021").first().text()}`; item.author = await cache_default.tryGet(userInfoApi, async () => { return (await ofetch_default(userInfoApi)).data.uname; }); item.description = $$1(".simditor-body").first().html(); item.category = $$1(".nTags a > span").toArray().map((item$1) => $$1(item$1).text().trim()); return item; }))); return { title: `elecfans ${atype} softs`, link: `https://www.elecfans.com/soft/${atype}/`, item: items }; } }; //#endregion export { route };