UNPKG

rsshub

Version:
48 lines (47 loc) 1.58 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/banyuetan/byt.ts const route = { path: "/byt/:time?", categories: ["new-media"], example: "/banyuetan/byt", parameters: { time: "时间,见下表,默认为每周" }, name: "时事大事库", maintainers: ["nczitzk"], description: `| 每周 | 每月 | | ------------- | ----- | | shishidashiku | yiyue |`, handler }; async function handler(ctx) { const { time = "shishidashiku" } = ctx.req.param(); const rootUrl = "http://www.banyuetan.org"; const currentUrl = `${rootUrl}/byt/${time}/index.html`; const $ = load(await rofetch(currentUrl)); const list = $(".byt_mian_image_list_con ul li a").slice(0, 10).toArray().map((item) => { const $item = $(item); return { link: new URL($item.attr("href"), rootUrl).href, title: $item.attr("title") }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const content = load(await rofetch(item.link)); return { ...item, description: content("#detail_content").html(), author: content(".detail_tit_source").text().replace("来源:", ""), pubDate: timezone(parseDate(content("meta[property=\"og:release_date\"]").attr("content")), 8) }; }))); return { title: $("title").text(), link: currentUrl, item: items }; } //#endregion export { route };