rsshub
Version:
Make RSS Great Again!
92 lines (90 loc) • 3.03 kB
JavaScript
import { n as init_esm_shims, t as __dirname } from "./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 { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as art } from "./render-BQo6B4tL.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import path from "node:path";
import { load } from "cheerio";
//#region lib/routes/gov/sh/wgj/wgj.ts
init_esm_shims();
const route = {
path: ["/sh/wgj/:page?", "/shanghai/wgj/:page?"],
categories: ["government"],
example: "/gov/sh/wgj",
parameters: { page: "页数,默认第 1 页" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{
source: ["wsbs.wgj.sh.gov.cn/"],
target: "/sh/wgj"
}],
name: "上海市文旅局审批公告",
maintainers: ["gideonsenku"],
handler,
url: "wsbs.wgj.sh.gov.cn/"
};
async function handler(ctx) {
const baseUrl = "http://wsbs.wgj.sh.gov.cn";
const currentUrl = `${baseUrl}/shwgj_ywtb/core/web/welcome/index!toResultNotice.action`;
const page = ctx.req.param("page") ?? 1;
const $ = load((await got_default({
method: "post",
url: currentUrl,
searchParams: {
flag: 1,
"pageDoc.pageNo": page
}
})).data);
const list = $("#div_md > table > tbody > tr > td:nth-child(1) > a").toArray().map((item) => {
item = $(item);
return {
title: item.prop("innerText").replaceAll(/\s/g, ""),
link: item.attr("href")
};
});
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const $$1 = load((await got_default({
method: "get",
url: baseUrl + item.link
})).data);
const dateText = $$1("div[align=\"right\"][style*=\"padding: 10px\"]").last().text().trim();
const hostingUnit = $$1("td:contains(\"举办单位:\")").next().text().trim();
const licenseNumber = $$1("td:contains(\"许可证号:\")").next().text().trim();
const performanceName = $$1("td:contains(\"演出名称:\")").next().text().trim();
const performanceDate = $$1("td:contains(\"演出日期:\")").next().text().trim();
const performanceVenue = $$1("td:contains(\"演出场所:\")").next().text().trim();
const mainActors = $$1("td:contains(\"主要演员:\")").next().text().trim();
const actorCount = $$1("td:contains(\"演员人数:\")").next().text().trim();
const showCount = $$1("td:contains(\"场次:\")").next().text().trim();
item.description = art(path.join(__dirname, "templates/wgj-5a172aec.art"), {
hostingUnit,
licenseNumber,
performanceName,
performanceDate,
performanceVenue,
mainActors,
actorCount,
showCount
});
item.pubDate = parseDate(dateText);
return item;
})));
return {
title: $("title").text(),
link: currentUrl,
item: items
};
}
//#endregion
export { route };