rsshub
Version:
Make RSS Great Again!
88 lines (86 loc) • 2.74 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import { t as timezone } from "./timezone-D8cuwzTY.mjs";
import { load } from "cheerio";
//#region lib/routes/xyu/notices.ts
const route = {
path: "/index/tzgg",
categories: ["university"],
example: "/xyu/index/tzgg",
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["www.xyc.edu.cn/index/tzgg.htm"] }],
name: "官网通知公告",
maintainers: ["JinMokai"],
handler,
url: "www.xyc.edu.cn/index/tzgg.htm"
};
async function handler() {
const baseUrl = "https://www.xyc.edu.cn";
const url = `${baseUrl}/index/tzgg.htm`;
const response = await ofetch_default(url);
if (!response) return {
title: "新余学院 - 通知公告",
link: url,
item: []
};
const $ = load(response);
const list = $(".text-list ul li").toArray().map((item) => {
const currentItem = $(item);
const link = currentItem.find("a").attr("href");
if (!link) return null;
const title = currentItem.find(".list-tx h3").text().trim();
const description = currentItem.find(".list-tx p").text().trim();
const day = currentItem.find(".date p").text().trim();
const dateText = `${currentItem.find(".date span").text().trim()}-${day.padStart(2, "0")}`;
return {
title,
link: new URL(link, baseUrl).href,
description: description || title,
pubDate: timezone(parseDate(dateText, "YYYY-MM-DD"), 8)
};
}).filter(Boolean);
return {
title: "新余学院 - 通知公告",
link: url,
item: await Promise.all(list.map((item) => cache_default.tryGet(item?.link || "", async () => {
if (!item) return "";
try {
const detailResponse = await ofetch_default(item?.link);
if (!detailResponse) return {
...item,
description: "该通知无法直接预览,请点击原文链接查看"
};
const content = load(detailResponse)(".v_news_content, .content, .article-content").html();
if (content) {
const $content = load(content);
$content("a").each(function() {
const a = $(this);
const href = a.attr("href");
if (href && !href.startsWith("http")) a.attr("href", new URL(href, baseUrl).href);
});
item.description = $content.html();
}
return item;
} catch {
return {
...item,
description: "该通知无法直接预览,请点击原文链接查看"
};
}
})))
};
}
//#endregion
export { route };