rsshub
Version:
Make RSS Great Again!
64 lines (62 loc) • 2.37 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 "./timezone-D8cuwzTY.mjs";
import { n as data_default, t as extractor_default } from "./extractor-D44Rpj0Q.mjs";
import { load } from "cheerio";
//#region lib/routes/sdu/wh/news.ts
const route = {
path: "/wh/news/:column?",
categories: ["university"],
example: "/sdu/wh/news/xyyw",
parameters: { column: "专栏名称,默认为校园要闻(`xyyw`)" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "新闻网",
maintainers: ["kxxt"],
handler,
description: `| 校园要闻 | 学生动态 | 综合新闻 | 山大视点 | 菁菁校园 | 校园简讯 | 玛珈之窗 | 热点专题 | 媒体视角 | 高教视野 | 理论学习 |
| -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
| xyyw | xsdt | zhxw | sdsd | jjxy | xyjx | mjzc | rdzt | mtsj | gjsy | llxx |`
};
async function handler(ctx) {
const column = ctx.req.param("column") ?? "xyyw";
const baseUrl = data_default.wh.news.url;
const $ = load((await got_default(baseUrl + data_default.wh.news.columns[column].url)).data);
const items = $(".n_newslist li");
const out = await Promise.all(items.map(async (index, item) => {
item = $(item);
const anchor = item.find("a");
const title = anchor.attr("title");
const href = anchor.attr("href");
const link = href.startsWith("http") ? href : baseUrl + href;
const { description, author, exactDate } = await cache_default.tryGet(link, () => extractor_default(link));
const span = item.find("span");
return {
title,
link,
description,
pubDate: exactDate ?? parseDate(span.text(), "YYYY/MM/DD"),
author
};
}));
return {
title: `${data_default.wh.news.name} ${data_default.wh.news.columns[column].name}`,
link: baseUrl + data_default.wh.news.columns[column].url,
item: out
};
}
//#endregion
export { route };