rsshub
Version:
Make RSS Great Again!
72 lines (70 loc) • 2.35 kB
JavaScript
import { n as init_esm_shims, t as __dirname } from "./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 art } from "./render-BQo6B4tL.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { t as timezone } from "./timezone-D8cuwzTY.mjs";
import path from "node:path";
import { load } from "cheerio";
//#region lib/routes/xjtu/std.ts
init_esm_shims();
const route = {
path: "/std/:category?",
categories: ["university"],
example: "/xjtu/std/zytz",
parameters: { category: "分类,见下表,默认为通知公告" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "科技在线",
maintainers: ["nczitzk"],
handler,
description: `| 通知公告 | 重要通知 | 项目申报 | 成果申报 | 信息快讯 |
| -------- | -------- | -------- | -------- | -------- |
| | zytz | xmsb | cgsb | xxkx |`
};
async function handler(ctx) {
const category = ctx.req.param("category") ?? "";
const rootUrl = "http://std.xjtu.edu.cn";
const currentUrl = `${rootUrl}/tzgg${category ? `/${category}` : ""}.htm`;
const $ = load((await got_default({
method: "get",
url: currentUrl
})).data);
let items = $(".c1017").toArray().map((item) => {
item = $(item);
return {
title: item.text(),
link: `${rootUrl}/${item.attr("href")}`
};
});
items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => {
const content = load((await got_default({
method: "get",
url: item.link
})).data);
item.description = art(path.join(__dirname, "templates/std-e15c7a71.art"), {
description: content("#vsb_newscontent").html(),
attachments: content("#vsb_newscontent").parent().next().next().next().html()
});
item.pubDate = timezone(parseDate(content("#vsb_newscontent").parent().prev().prev().text().split(" ")[0], "YYYY年MM月DD日 HH:mm"), 8);
return item;
})));
return {
title: $("title").text(),
link: currentUrl,
item: items
};
}
//#endregion
export { route };