rsshub
Version:
Make RSS Great Again!
95 lines (93 loc) • 2.59 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { t as timezone } from "./timezone-D8cuwzTY.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) => {
item = $(item);
return {
title: item.find("a").attr("title"),
description: item.find("a").first().text(),
link: "https://zbb.nju.edu.cn" + item.find("a").attr("href"),
pubDate: timezone(parseDate(item.find("span").first().text(), "YYYY-MM-DD"), 8)
};
})
};
} else {
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) => {
item = $(item);
return {
title: item.find("a").attr("title"),
description: item.find("a").first().text(),
link: "https://zbb.nju.edu.cn" + item.find("a").attr("href"),
pubDate: timezone(parseDate(item.find("span").first().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 };