UNPKG

rsshub

Version:
59 lines (57 loc) 2.23 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { load } from "cheerio"; //#region lib/routes/hitsz/article.ts const route = { path: "/article/:category?", categories: ["university"], example: "/hitsz/article/id-74", parameters: { category: "分类名,默认为校园动态" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "新闻中心", maintainers: ["xandery-geek"], handler, description: `| 校区要闻 | 媒体报道 | 综合新闻 | 校园动态 | 讲座论坛 | 热点专题 | 招标信息 | 重要关注 | | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | | id-116 | id-80 | id-75 | id-77 | id-78 | id-79 | id-81 | id-124 |` }; async function handler(ctx) { const host = "https://www.hitsz.edu.cn"; const link = `${host}/article/${ctx.req.param("category") ?? "id-77"}.html`; const $ = load((await got_default(link)).data); const category_name = $("div.title_page").text().trim(); const lists = $(".mainside_news ul li").toArray().map((el) => ({ title: $("a", el).text().trim(), link: `${host}${$("a", el).attr("href")}`, pubDate: timezone(parseDate($("span[class=date]", el).text()), 8) })); const items = await Promise.all(lists.map((item) => cache_default.tryGet(item.link, async () => { const $$1 = load((await got_default.get(item.link)).data); item.description = $$1("div.edittext").html().trim(); item.pubDate = timezone(parseDate($$1(".item").first().text().replace("发布时间:", "")), 8); return item; }))); return { title: "哈尔滨工业大学(深圳)-" + category_name, link, description: "哈尔滨工业大学(深圳)-" + category_name, item: items }; } //#endregion export { route };