rsshub
Version:
Make RSS Great Again!
51 lines (50 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 cache_default } from "./cache-CiDoUSLo.mjs";
import { t as timezone } from "./timezone-DE--ze1V.mjs";
import { load } from "cheerio";
//#region lib/routes/ahau/main.ts
const route = {
path: "/main/:type",
categories: ["university"],
example: "/ahau/main/xnyw",
parameters: { type: "类型名" },
name: "安农大官网新闻",
maintainers: ["SimonHu-HN"],
handler,
description: `| 校内要闻 | 院部动态 |
| -------- | -------- |
| xnyw | ybdt |`
};
async function handler(ctx) {
const { type } = ctx.req.param();
const link = `https://news.ahau.edu.cn/index/${type}.htm`;
const $ = load(await rofetch(link));
const title = $(".listing > h2").text().trim();
const list = $(".newlist02 li a").slice(0, 10).toArray();
const result = await Promise.all(list.map((item) => {
const $item = $(item);
const itemUrl = new URL($item.attr("href"), link).href;
const itemTitle = $item.attr("title");
const pubDate = timezone(parseDate($item.find("span").text()), 8);
return cache_default.tryGet(itemUrl, async () => {
const $$ = load(await rofetch(itemUrl));
return {
title: itemTitle,
link: itemUrl,
author: "安农大新闻",
guid: itemUrl,
description: $$(".v_news_content").html(),
pubDate
};
});
}));
return {
title: `安徽农业大学新闻网 - ${title}`,
link,
description: `安徽农业大学新闻网 - ${title}`,
item: result
};
}
//#endregion
export { route };