UNPKG

rsshub

Version:
53 lines (52 loc) 1.8 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as parseDate } from "./parse-date-CjhZE69i.mjs"; import { t as cache_default } from "./cache-CiDoUSLo.mjs"; import { t as timezone } from "./timezone-DE--ze1V.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 $ = load(await rofetch(link)); 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 () => { item.description = load(await rofetch(item.link))(".wp_articlecontent").html(); return item; }); })); return { title: `浙江工业大学 - ${$("head title").text()}`, link, item: items }; } //#endregion export { route };