rsshub
Version:
Make RSS Great Again!
57 lines (56 loc) • 1.75 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { t as timezone } from "./timezone-DE--ze1V.mjs";
import { load } from "cheerio";
//#region lib/routes/lyu/news.ts
const baseUrl = "https://www.lyu.edu.cn/";
const route = {
path: "/news/:type",
categories: ["university"],
example: "/lyu/news/ldyw",
parameters: { type: "分类名" },
name: "新闻",
maintainers: ["ueiu"],
handler,
description: `| 临大要闻 | 信息公告 |
| -------- | -------- |
| ldyw | xxgg |`
};
async function handler(ctx) {
const map = /* @__PURE__ */ new Map([["ldyw", {
title: "临大要闻",
path: "8125"
}], ["xxgg", {
title: "信息公告",
path: "8126"
}]]);
const { type } = ctx.req.param();
const { title, path } = map.get(type);
const fullUrl = `${baseUrl}${path}/list.htm`;
const $ = load(await rofetch(fullUrl));
const list = $(".news_list li").toArray().map((item) => {
const $item = $(item);
return {
title: $item.find(".news_title a").text(),
link: new URL($item.find(".news_title a").attr("href"), baseUrl).href,
author: "临沂大学",
pubDate: timezone(parseDate(`${$item.find(".news_days").text()}-${$item.find(".news_year").text()}`), 8)
};
});
const items = await Promise.all(list.map((item) => item.link.endsWith(".psp") ? item : cache_default.tryGet(item.link, async () => {
const $detail = load(await rofetch(item.link));
return {
...item,
description: $detail(".wp_articlecontent").html()
};
})));
return {
title: `临沂大学 - ${title}`,
link: fullUrl,
description: `临沂大学 - ${title}`,
item: items
};
}
//#endregion
export { route };