rsshub
Version:
Make RSS Great Again!
45 lines (44 loc) • 1.57 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as timezone } from "./timezone-DE--ze1V.mjs";
import { load } from "cheerio";
//#region lib/routes/dlmu/news.ts
const route = {
path: "/news/:type",
categories: ["university"],
example: "/dlmu/news/hdyw",
parameters: { type: "默认为 `hdyw`" },
name: "新闻网",
maintainers: ["arjenzhou"],
handler,
description: `| 海大要闻 | 媒体海大 | 综合新闻 | 院系风采 | 海大校报 | 理论园地 | 海大讲坛 | 艺文荟萃 |
| :------: | :------: | :------: | :------: | :------: | :------: | :------: | :------: |
| hdyw | mthd | zhxw | yxfc | hdxb | llyd | hdjt | ywhc |`
};
const baseUrl = "https://news.dlmu.edu.cn";
const map = {
hdyw: "/hdyw.htm",
mthd: "/mthd.htm",
zhxw: "/zhxw.htm",
yxfc: "/yxfc.htm",
hdxb: "/hdxb.htm",
llyd: "/llyd.htm",
hdjt: "/hdjt.htm",
ywhc: "/ywhc.htm"
};
async function handler(ctx) {
const { type } = ctx.req.param();
const $ = load(await rofetch(Object.hasOwn(map, type) ? `${baseUrl}${map[type]}` : `${baseUrl}/hdyw.htm`));
return {
link: baseUrl,
title: "大连海事大学新闻",
item: $(".n-Box .n-right .n-pic-box .n-news dl").slice(0, 10).toArray().map((element) => ({
link: new URL($("dd a", element).attr("href"), baseUrl).href,
title: $("dd a", element).text(),
description: $("dd p", element).text(),
pubDate: timezone(parseDate($("i", element).text().slice(1, -1)), 8)
}))
};
}
//#endregion
export { route };