UNPKG

rsshub

Version:
71 lines (70 loc) 1.88 kB
import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; import { t as got_default } from "./got-DUpa1V3-.mjs"; import { t as timezone } from "./timezone-UiMFOuvL.mjs"; import { load } from "cheerio"; //#region lib/routes/aliyun/notice.ts const typeMap = { 0: "9004748", 1: "9004749", 2: "9213612", 3: "8314815", 4: "9222707" }; const route = { path: "/notice/:type?", categories: ["programming"], example: "/aliyun/notice", parameters: { type: "N" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "公告", maintainers: ["muzea"], handler, description: `| 类型 | type | | -------- | ---- | | 全部 | | | 升级公告 | 1 | | 安全公告 | 2 | | 备案公告 | 3 | | 其他 | 4 |` }; async function handler(ctx) { const type = ctx.req.param("type"); const url = `https://help.aliyun.com/noticelist/${typeMap[type] || typeMap[0]}.html`; const response = await got_default({ method: "get", url }); const $ = load(response.data); const list = $("ul > li.notice-li").toArray().map((e) => { const element = $(e); const title = element.find("a").text().trim(); const link = "https://help.aliyun.com" + element.find("a").attr("href").trim(); const date = element.find(".y-right").text(); return { title, description: "", link, pubDate: timezone(parseDate(date), 8) }; }); const result = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const itemReponse = await got_default(item.link); item.description = load(itemReponse.data)("#se-knowledge").html() ?? ""; return item; }))); return { title: $("title").text().trim(), link: url, item: result }; } //#endregion export { route };