UNPKG

rsshub

Version:
70 lines (69 loc) 2 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/shanghaitech/activity.ts const baseUrl = "https://www.shanghaitech.edu.cn"; const route = { path: "/activity", categories: ["university"], example: "/shanghaitech/activity", radar: [{ source: ["www.shanghaitech.edu.cn/hd/list.htm"] }], name: "活动通知", maintainers: ["nczitzk"], handler, url: "www.shanghaitech.edu.cn/hd/list.htm" }; async function handler(ctx) { const link = `${baseUrl}/hd/list.htm`; const limit = ctx.req.query("limit") ? Number(ctx.req.query("limit")) : 20; const list = (await rofetch(`${baseUrl}/_wp3services/generalQuery?queryObj=articles`, { method: "POST", headers: { Accept: "application/json, text/javascript, */*; q=0.01", Referer: link, "X-Requested-With": "XMLHttpRequest" }, body: new URLSearchParams({ siteId: "8", columnId: "15079", pageIndex: "1", rows: String(limit), orders: JSON.stringify([{ field: "f1", type: "desc" }]), returnInfos: JSON.stringify([{ field: "title", name: "title" }, { field: "f2", name: "f2" }]), conditions: JSON.stringify([{ field: "scope", value: 0, judge: "=" }]) }), parseResponse: JSON.parse })).data.map((item) => ({ title: item.title, link: item.url.replace(/^http:/, "https:"), author: item.f2, pubDate: timezone(parseDate(item.publishTime), 8) })); return { title: "上海科技大学 - 活动", link, item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const $ = load(await rofetch(item.link)); $(".mr .news_imgs a.dj").remove(); item.description = ($(".mr .news_imgs").html() ?? "") + $("div.wp_articlecontent").html(); return item; }))) }; } //#endregion export { route };