rsshub
Version:
Make RSS Great Again!
55 lines (54 loc) • 1.77 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/shou/www.ts
const host = "https://www.shou.edu.cn";
const dict = {
zbxx: "招标信息",
tzgg: "通知公告",
yw: "要闻",
mtjj: "媒体聚焦",
xsjz: "学术讲座",
xsqy: "科技前沿"
};
const route = {
path: "/www/:type",
categories: ["university"],
example: "/shou/www/tzgg",
parameters: { type: "消息类型" },
name: "官网信息",
maintainers: ["Swung0x48"],
handler,
description: `| 通知公告 | 招标信息 | 要闻 | 媒体聚焦 | 学术讲座 | 科技前沿 |
| -------- | -------- | ---- | -------- | -------- | -------- |
| tzgg | zbxx | yw | mtjj | xsjz | xsqy |`
};
async function handler(ctx) {
const { type } = ctx.req.param();
const link = `${host}/${type}/list.htm`;
const $ = load(await rofetch(link));
const items = await Promise.all($(".col_news_item").slice(0, 10).toArray().map((item) => {
const $item = $(item);
const itemUrl = new URL($item.find(".col_news_title a").attr("href"), host).href;
return cache_default.tryGet(itemUrl, async () => {
const $detail = load(await rofetch(itemUrl));
return {
title: $item.find(".col_news_title a").text(),
link: itemUrl,
guid: itemUrl,
pubDate: timezone(parseDate($item.find(".col_news_date").text()), 8),
description: $detail(".wp_articlecontent").text()
};
});
}));
return {
title: `上海海洋大学 ${dict[type]}`,
link,
description: "上海海洋大学 官网信息",
item: items
};
}
//#endregion
export { route };