rsshub
Version:
Make RSS Great Again!
53 lines (52 loc) • 1.69 kB
JavaScript
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/hbsea/index.ts
const route = {
path: "/:id",
categories: ["government"],
example: "/hbsea/19",
parameters: { id: "栏目 id,见下表" },
radar: [{
source: ["www.hbsea.org.cn/portal/list/index/id/:id.html"],
target: "/:id"
}],
name: "栏目",
maintainers: ["tudou027"],
handler,
description: `| 栏目 | id |
| :------: | :-: |
| 通知公告 | 18 |
| 协会动态 | 19 |
| 行业资讯 | 20 |
| 企业之窗 | 21 |`
};
const rootUrl = "http://www.hbsea.org.cn";
async function handler(ctx) {
const { id } = ctx.req.param();
const currentUrl = `${rootUrl}/portal/list/index/id/${id}.html`;
const $ = load(await rofetch(currentUrl));
const list = $("ul.list li a").toArray().map((item) => {
const $item = $(item);
return {
title: $item.find("b").text(),
link: new URL($item.attr("href"), rootUrl).href,
pubDate: timezone(parseDate($item.find(".text i").text(), "YYYY-MM-DD"), 8)
};
});
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const content = load(await rofetch(item.link));
item.description = content(".text-content").html();
item.pubDate = timezone(parseDate(content("meta[name=\"PubDate\"]").attr("content"), "YYYY-MM-DD HH:mm:ss"), 8);
return item;
})));
return {
title: `湖北软协 - ${$(".gl-title-box span").text()}`,
link: currentUrl,
item: items
};
}
//#endregion
export { route };