UNPKG

rsshub

Version:
57 lines (56 loc) 2.05 kB
import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs"; import { t as cache_default } from "./cache-BkqOokyU.mjs"; import { t as got_default } from "./got-BTowW50G.mjs"; import { t as timezone } from "./timezone-BBvDwS_3.mjs"; import { load } from "cheerio"; //#region lib/routes/buaa/news/index.ts const route = { path: "/news/:type", categories: ["university"], example: "/buaa/news/zhxw", parameters: { type: "新闻版块" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "新闻网", maintainers: ["AlanDecode"], handler, description: `| 综合新闻 | 信息公告 | 学术文化 | 校园风采 | 科教在线 | 媒体北航 | 专题新闻 | 北航人物 | | -------- | --------- | ------------ | --------- | --------- | --------- | -------- | -------- | | zhxw | xxgg\\_new | xsjwhhd\\_new | xyfc\\_new | kjzx\\_new | mtbh\\_new | ztxw | bhrw |` }; async function handler(ctx) { const baseUrl = "https://news.buaa.edu.cn"; const { data: response, url: link } = await got_default(`${baseUrl}/${ctx.req.param("type")}.htm`); const $ = load(response); const title = $(".subnav span").text().trim(); const list = $(".mainleft > .listlefttop > .listleftop1").toArray().map((item_) => { const item = $(item_); const title = item.find("h2 > a"); return { title: title.text(), link: new URL(title.attr("href"), baseUrl).href, pubDate: timezone(parseDate(item.find("h2 em").text(), "[YYYY-MM-DD]"), 8) }; }); const result = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const $ = load((await got_default(item.link)).data); item.description = $(".v_news_content").html(); item.author = $(".vsbcontent_end").text().trim(); return item; }))); return { title: `北航新闻 - ${title}`, link, description: `北京航空航天大学新闻网 - ${title}`, language: "zh-CN", item: result }; } //#endregion export { route };