rsshub
Version:
Make RSS Great Again!
49 lines (48 loc) • 1.55 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/ahau/cs-news.ts
const route = {
path: "/cs_news/:type",
categories: ["university"],
example: "/ahau/cs_news/tzgg",
parameters: { type: "类型名" },
radar: [{
source: ["xzxy.ahau.edu.cn/index/:type.htm"],
target: "/cs_news/:type"
}],
name: "人工智能学院",
maintainers: ["SimonHu-HN"],
handler,
url: "xzxy.ahau.edu.cn",
description: `| 学院要闻 | 通知公告 |
| -------- | -------- |
| xyyw | tzgg |`
};
async function handler(ctx) {
const { type } = ctx.req.param();
const link = `https://xzxy.ahau.edu.cn/index/${type}.htm`;
const $ = load(await rofetch(link));
const list = $(".txt-list li.flex").toArray().map((item) => {
const $item = $(item);
const a = $item.find("a");
return {
title: a.attr("title") ?? a.text(),
link: new URL(a.attr("href"), link).href,
pubDate: timezone(parseDate($item.find("span").text(), "YYYY-MM-DD"), 8)
};
});
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
item.description = load(await rofetch(item.link))(".v_news_content").html()?.trim();
return item;
})));
return {
title: `安徽农业大学人工智能学院 - ${$(".main-title h2").text().trim()}`,
link,
item: items
};
}
//#endregion
export { route };