UNPKG

rsshub

Version:
73 lines (71 loc) 2.07 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./ofetch-DKl_Ma9g.mjs"; import { t as parseDate } from "./parse-date-r5WDWHno.mjs"; import "./is-worker-DESPicPc.mjs"; import { t as cache_default } from "./cache-SV6W5EPy.mjs"; import "./helpers-Bo4JQYdN.mjs"; import { t as got_default } from "./got-CO-ndVl2.mjs"; import { load } from "cheerio"; //#region lib/routes/zju/list.ts const host = "https://www.zju.edu.cn/"; const route = { path: "/list/:type", categories: ["university"], example: "/zju/list/xs", parameters: { type: "`xs`为学术,`xw`为新闻,`5461`是图片新闻,`578`是浙大报道,具体参数参考左侧的菜单" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "普通栏目 如学术 / 图片 / 新闻等", maintainers: ["Jeason0228"], handler }; async function handler(ctx) { const link = host + (ctx.req.param("type") ?? "xs") + `/list.htm`; const $ = load((await got_default({ method: "get", url: link, headers: { Referer: host } })).data); function sortUrl(e) { return e.search("redirect") === -1 ? e : link; } const list = $("#wp_news_w7 ul.news li").toArray().map((element) => { return { title: $(element).find("a").attr("title"), link: sortUrl($(element).find("a").attr("href")), date: $(element).text().match(/\d{4}-\d{2}-\d{2}/)[0] }; }); const out = await Promise.all(list.map((info) => { const title = info.title; const date = info.date; const itemUrl = new URL(info.link, host).href; return cache_default.tryGet(itemUrl, async () => { return { title, link: itemUrl, description: load((await got_default({ method: "get", url: itemUrl, headers: { Referer: link } })).data)(".right_content").html(), pubDate: parseDate(date) }; }); })); return { title: `浙江大学` + $("ul.submenu .selected").text(), link, item: out }; } //#endregion export { route };