rsshub
Version:
Make RSS Great Again!
63 lines (61 loc) • 2.3 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 { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { load } from "cheerio";
//#region lib/routes/gov/miit/yjzj.ts
const rootUrl = "https://www.miit.gov.cn";
const route = {
path: "/miit/yjzj",
categories: ["government"],
example: "/gov/miit/yjzj",
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["miit.gov.cn/gzcy/yjzj/index.html"] }],
name: "意见征集",
maintainers: ["Fatpandac"],
handler,
url: "miit.gov.cn/gzcy/yjzj/index.html"
};
async function handler() {
const url = `${rootUrl}/gzcy/yjzj/index.html`;
const cookieResponse = await got_default(url);
const cookie = cookieResponse.headers["set-cookie"][0].split(";")[0];
const indexContent = load(cookieResponse.data);
const dataRequestUrl = indexContent("div.clist_con > script:nth-child(2)").toArray().map((item) => ({
url: `${rootUrl}${indexContent(item).attr("url")}`,
queryData: JSON.parse(indexContent(item).attr("querydata").replaceAll("\"", "|").replaceAll("'", "\"").replaceAll("|", "\""))
}))[0];
const $ = load((await got_default({
method: "get",
url: `${dataRequestUrl.url}?${Object.keys(dataRequestUrl.queryData).map((key) => `${key}=${dataRequestUrl.queryData[key]}`).join("&")}`,
headers: { Cookie: cookie }
})).data.data.html);
const list = $("ul > li").toArray().map((item) => ({
title: $(item).find("a").text(),
link: new URL($(item).find("a").attr("href"), rootUrl).href,
pubDate: parseDate($(item).find("span").text(), "YYYY-MM-DD")
}));
return {
title: `工业和信息化部 - 意见征集`,
link: url,
item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
item.description = load((await got_default(item.link)).data)("#con_con").html().replaceAll(/(<iframe.*?src=")(.*?)(".*?>)/g, "$1" + rootUrl + "$2$3");
return item;
})))
};
}
//#endregion
export { route };