rsshub
Version:
Make RSS Great Again!
87 lines (86 loc) • 2.34 kB
JavaScript
import { t as parseDate } from "./parse-date-Cr0wQjV_.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/nju/zbb.ts
const route = {
path: "/zbb/:type",
categories: ["university"],
example: "/nju/zbb/cgxx",
parameters: { type: "分类名" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "招标办公室",
maintainers: ["ret-1"],
handler,
description: `| 采购信息 | 成交公示 | 政府采购意向公开 |
| -------- | -------- | ---------------- |
| cgxx | cjgs | zfcgyxgk |`
};
async function handler(ctx) {
const type = ctx.req.param("type");
if (type === "zfcgyxgk") {
const url = "https://zbb.nju.edu.cn/zfcgyxgk/index.chtml";
const data = (await got_default({
method: "get",
url
})).data;
const $ = load(data);
return {
title: "政府采购意向公开",
link: url,
item: $("dd[cid]").toArray().map((item) => {
const $item = $(item);
return {
title: $item.find("a").attr("title"),
description: $item.find("a").text(),
link: "https://zbb.nju.edu.cn" + $item.find("a").attr("href"),
pubDate: timezone(parseDate($item.find("span").text(), "YYYY-MM-DD"), 8)
};
})
};
}
const title_dict = {
cgxx: "采购信息",
cjgs: "成交公示"
};
const category_dict = {
hw: "货物类",
gc: "工程类",
fw: "服务类"
};
const items = await Promise.all(Object.keys(category_dict).map(async (c) => {
const data = (await got_default({
method: "get",
url: `https://zbb.nju.edu.cn/${type}${c}/index.chtml`
})).data;
const $ = load(data);
return $("dd[cid]").toArray().map((item) => {
const $item = $(item);
return {
title: $item.find("a").attr("title"),
description: $item.find("a").text(),
link: "https://zbb.nju.edu.cn" + $item.find("a").attr("href"),
pubDate: timezone(parseDate($item.find("span").text(), "YYYY-MM-DD"), 8),
category: category_dict[c]
};
});
}));
return {
title: title_dict[type],
link: `https://zbb.nju.edu.cn/${type}hw/index.chtml`,
item: [
...items[0],
...items[1],
...items[2]
]
};
}
//#endregion
export { route };