rsshub
Version:
Make RSS Great Again!
75 lines (73 loc) • 2.23 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 { load } from "cheerio";
//#region lib/routes/neu/news.ts
const baseUrl = "https://neunews.neu.edu.cn";
const route = {
path: "/news/:type",
categories: ["university"],
example: "/neu/news/ddyw",
parameters: { type: "种类名,见下表" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["neunews.neu.edu.cn/:type/list.htm"] }],
name: "新闻网",
maintainers: ["JeasonLau"],
handler,
description: `| 种类名 | 参数 |
| -------- | ---- |
| 东大要闻 | ddyw |
| 媒体东大 | mtdd |
| 通知公告 | tzgg |
| 新闻纵横 | xwzh |
| 人才培养 | rcpy |
| 学术科研 | xsky |
| 英文新闻 | 217 |
| 招生就业 | zsjy |
| 考研出国 | kycg |
| 校园文学 | xywx |
| 校友风采 | xyfc |
| 时事热点 | ssrd |
| 教育前沿 | jyqy |
| 文化体育 | whty |
| 最新科技 | zxkj |`
};
async function handler(ctx) {
const newsUrl = `${baseUrl}/${ctx.req.param("type")}/list.htm`;
const data = (await got_default(newsUrl)).data;
const $ = load(data);
const items = $(".column-news-list > .news_list > .news").toArray().map((item) => {
item = $(item);
return {
title: item.find("a").attr("title"),
link: new URL(item.find("a").attr("href"), baseUrl).href,
pubDate: parseDate(item.find(".news_meta").text(), "YYYY-MM-DD")
};
});
const results = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => {
const $$1 = load((await got_default(item.link)).data);
item.author = $$1(".arti-metas").text().split("更新日期")[0];
item.description = $$1(".article_content").html();
return item;
})));
return {
title: `东北大学新闻网-${$("head title").text()}`,
link: newsUrl,
item: results
};
}
//#endregion
export { route };