rsshub
Version:
Make RSS Great Again!
45 lines (44 loc) • 1.61 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/qzcea/index.ts
const route = {
path: "/:caty?",
categories: ["government"],
example: "/qzcea",
parameters: { caty: "分类 id,默认为 `1`" },
name: "新闻动态",
maintainers: ["nczitzk"],
description: `| 新闻动态 | 协会动态 | 通知公告 | 会员风采 | 政策法规 | 电商资讯 |
| -------- | -------- | -------- | -------- | -------- | -------- |
| 1 | 2 | 3 | 5 | 14 | 18 |`,
handler
};
async function handler(ctx) {
const { caty = "1" } = ctx.req.param();
const rootUrl = "http://www.qzcea.org";
const currentUrl = `${rootUrl}/usernewscatname_nc${caty}`;
const $ = load(await rofetch(currentUrl));
$("a.news-more").remove();
const list = $("li.clearfix div.news-right a").toArray().slice(0, 10).map((item) => {
const $item = $(item);
return {
title: $item.text(),
link: `${rootUrl}${$item.attr("href")}`,
pubDate: timezone(parseDate($item.next().text().replace("时间 :", "")), 8)
};
});
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
item.description = load(await rofetch(item.link))("div.newm").html();
return item;
})));
return {
title: `${$("title").text()} - 泉州市跨境电子商务协会`,
link: currentUrl,
item: items
};
}
//#endregion
export { route };