UNPKG

rsshub

Version:
44 lines (43 loc) 1.54 kB
import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs"; import { t as cache_default } from "./cache-BkqOokyU.mjs"; import { t as got_default } from "./got-BTowW50G.mjs"; import { load } from "cheerio"; //#region lib/routes/cas/is/index.ts const baseUrl = "https://is.cas.cn"; const route = { path: "/is/:path{.+}", categories: ["university"], example: "/cas/is/xwdt2016/tzgg2016", parameters: { path: "路径,可在 URL 找到" }, name: "软件研究所", maintainers: ["Misaka13514"], handler, description: `| 通知公告 | 科技动态 | 科普动态 | | ----------------- | ----------------- | ----------------- | | xwdt2016/tzgg2016 | xwdt2016/kjdt2016 | kxcb2016/kpdt2016 |` }; async function handler(ctx) { const path = ctx.req.param("path"); const response = await got_default(`${baseUrl}/${path}/`); const $ = load(response.data); const items = $(".list-news ul li").toArray().map((item) => { const $item = $(item); return { title: $item.find("a").text(), link: new URL($item.find("a").attr("href"), response.url).href, pubDate: parseDate($item.find("span").text().replaceAll("[]", "")) }; }); await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => { if (!item.link.startsWith(`${baseUrl}/`)) return item; item.description = load((await got_default(item.link)).data)(".TRS_Editor").html(); return item; }))); return { title: $("head title").text(), link: `${baseUrl}/${path}`, item: items }; } //#endregion export { route };