UNPKG

rsshub

Version:
55 lines (54 loc) 1.83 kB
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 { n as outPlaywright } from "./playwright-Dd_brOFk.mjs"; import { load } from "cheerio"; //#region lib/routes/bupt/grs.ts const route = { path: "/grs", categories: ["university"], example: "/bupt/grs", features: { requirePuppeteer: true, antiCrawler: true }, radar: [{ source: ["grs.bupt.edu.cn/tzgg.htm"] }], name: "研究生院通知", maintainers: ["jiaming-shi"], handler, url: "grs.bupt.edu.cn/tzgg.htm" }; const baseUrl = "https://grs.bupt.edu.cn/tzgg.htm"; async function handler() { const context = await outPlaywright(); const page = await context.newPage(); await page.route("**/*", (route) => { const request = route.request(); request.resourceType() === "document" || request.resourceType() === "script" ? route.continue() : route.abort(); }); await page.goto(baseUrl, { waitUntil: "networkidle" }); const $ = load(await page.content()); const list = $(".n_list_pic li a").toArray().map((item) => { const $item = $(item); return { title: $item.attr("title"), link: new URL($item.attr("href"), baseUrl).href, pubDate: timezone(parseDate($item.find("i").text()), 8) }; }); const out = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const $ = load(await (await context.request.get(item.link)).text()); $(".v_news_content style").remove(); item.description = $(".v_news_content").html(); item.author = $(".bbt span:contains(\"作者:\")").text().replace("作者:", ""); return item; }))); await context.close(); return { title: "北京邮电大学研究生院 - 通知公告", link: baseUrl, item: out }; } //#endregion export { route };