UNPKG

rsshub

Version:
66 lines (65 loc) 1.97 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 { t as timezone } from "./timezone-BBvDwS_3.mjs"; import { r as finishArticleItem } from "./wechat-mp-BPi_ETC7.mjs"; import { load } from "cheerio"; //#region lib/routes/njupt/jwc.ts const host = "https://jwc.njupt.edu.cn"; const map = { notice: "/1594", news: "/1596" }; const route = { path: "/jwc/:type?", categories: ["university"], example: "/njupt/jwc/notice", parameters: { type: "默认为 `notice`" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "教务处通知与新闻", maintainers: ["shaoye"], handler, description: `| 通知公告 | 教务快讯 | | -------- | -------- | | notice | news |` }; async function handler(ctx) { const type = ctx.req.param("type") ?? "notice"; const link = host + map[type] + "/list.htm"; const $ = load((await got_default({ method: "get", url: link })).data); const list = $(".news_list li").toArray().map((item) => { const $item = $(item); return { title: $item.find(".news_title").text(), link: new URL($item.find("a").attr("href"), host).href, pubDate: timezone(parseDate($item.find(".news_meta").text()), 8) }; }); const items = await Promise.all(list.map((item) => { if (new URL(item.link).host === "mp.weixin.qq.com") return finishArticleItem({ ...item, guid: item.link }); return cache_default.tryGet(item.link, async () => { item.description = load((await got_default(item.link)).data)(".wp_articlecontent").html() ?? "该通知无法直接预览,请点击原文链接查看"; return item; }); })); return { title: `南京邮电大学 -- ${type === "news" ? "教务快讯" : "通知公告"}`, link, item: items }; } //#endregion export { route };