rsshub
Version:
Make RSS Great Again!
57 lines (55 loc) • 1.8 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { t as timezone } from "./timezone-D8cuwzTY.mjs";
import { load } from "cheerio";
//#region lib/routes/byau/xinwen/index.ts
const route = {
path: "/news/:type_id",
categories: ["university"],
example: "/byau/news/3674",
parameters: { type_id: "栏目类型(从菜单栏获取对应 ID)" },
radar: [{
source: ["xinwen.byau.edu.cn/:type_id/list.htm"],
target: "/news/:type_id"
}],
name: "新闻网",
maintainers: ["ueiu"],
handler,
url: "xinwen.byau.edu.cn",
description: `| 学校要闻 | 校园动态 |
| ---- | ----------- |
| 3674 | 3676 |`
};
async function handler(ctx) {
const baseUrl = "http://xinwen.byau.edu.cn/";
const url = `${baseUrl}${ctx.req.param("type_id")}/list.htm`;
const $ = load((await got_default(url)).data);
const list = $(".news").toArray().map((item) => {
const $$ = load(item);
const originalItemUrl = $$("a").attr("href");
const itemUrl = originalItemUrl.startsWith("http") ? originalItemUrl : new URL(originalItemUrl, baseUrl).href;
return {
title: $$("a").text(),
link: itemUrl,
pubDate: timezone(parseDate($$(".news_meta").text()), 8)
};
});
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
item.description = load((await got_default(item.link)).data)(".col_news_con").html();
return item;
})));
return {
title: $("title").text(),
link: url,
item: items
};
}
//#endregion
export { route };