rsshub
Version:
Make RSS Great Again!
55 lines (54 loc) • 1.85 kB
JavaScript
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs";
import { t as parseDate } from "./parse-date-3kcy2Eau.mjs";
import { t as cache_default } from "./cache-C1Y-9qDV.mjs";
import { t as timezone } from "./timezone-UiMFOuvL.mjs";
import { load } from "cheerio";
//#region lib/routes/zjut/index.ts
const host = "https://www.zjut.edu.cn";
const route = {
path: "/:type?",
categories: ["university"],
example: "/zjut/4528",
parameters: { type: "板块 id,默认为 4528,即通知公告" },
radar: [{
source: ["www.zjut.edu.cn/:type/list.htm"],
target: "/:type"
}],
name: "浙江工业大学",
maintainers: ["junbaor"],
handler,
url: "www.zjut.edu.cn",
description: `| 学术探索 | 三创・人物 | 通知公告 | 美誉工大 | 智库工大 | 学术动态 |
| -------- | ---------- | -------- | -------- | -------- | ---------- |
| 4526 | 4527 | 4528 | 5389 | 5390 | xsdt\\_4662 |`
};
async function handler(ctx) {
const { type = "4528" } = ctx.req.param();
const link = `${host}/${type}/list.htm`;
const response = await rofetch(link);
const $ = load(response);
const list = $(".col_news_list .news_list li.news").toArray().map((item) => {
const $item = $(item);
const a = $item.find(".news_title a");
return {
title: a.text(),
link: new URL(a.attr("href"), host).href,
pubDate: timezone(parseDate($item.find(".news_meta").text(), "YYYY-MM-DD"), 8)
};
});
const items = await Promise.all(list.map((item) => {
if (!item.link.startsWith(`${host}/`)) return item;
return cache_default.tryGet(item.link, async () => {
const response = await rofetch(item.link);
item.description = load(response)(".wp_articlecontent").html();
return item;
});
}));
return {
title: `浙江工业大学 - ${$("head title").text()}`,
link,
item: items
};
}
//#endregion
export { route };