rsshub
Version:
Make RSS Great Again!
176 lines (173 loc) • 8.01 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 { t as logger_default } from "./logger-Czu8UMNd.mjs";
import { t as ofetch_default } from "./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 "./proxy-Db7uGcYb.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { t as timezone } from "./timezone-D8cuwzTY.mjs";
import { n as puppeteer_default } from "./puppeteer-DGmvuGvT.mjs";
import path from "node:path";
import { load } from "cheerio";
//#region lib/routes/gov/hangzhou/zjzwfw.ts
init_esm_shims();
async function crawler(item, browser) {
try {
let response = "";
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on("request", (request) => {
const resourceType = request.resourceType();
if ([
"document",
"script",
"stylesheet",
"xhr"
].includes(resourceType)) request.continue();
else request.abort();
});
await page.goto(item.link, {
waitUntil: "networkidle0",
timeout: 29e3
});
await page.evaluate((selector) => document.querySelector(selector).click(), ".item-left .item .title .button");
await page.waitForSelector(".item-left .item .bg_box div:nth-child(16)", { timeout: 5e3 });
response = await page.content();
return response || "";
} catch (error) {
logger_default.error("Error when visiting /gov/hangzhou/zwfw:", error);
return "";
}
}
function analyzer(box) {
return {
serviceInfo: {
serviceTarget: box.find(".row:nth(1)>div:nth(1)").find(".inner").children().first().attr("content"),
processingMethods: box.find(".row:nth(1)>div:nth(3)").find(".inner").text(),
processingLocation: box.find(".row:nth(2)>div:nth(1)").find(".inner").text(),
processingTime: box.find(".row:nth(3)>div:nth(1)").find(".inner").text()
},
applicationInfo: {
acceptanceConditions: box.find(".row:nth(5)>div:nth(1)").find(".inner").text(),
prohibitedRequirements: box.find(".row:nth(6)>div:nth(1)").find(".inner").text(),
quantityRestrictions: box.find(".row:nth(7)>div:nth(1)").find(".inner").text()
},
resultInfo: {
approvalResult: box.find(".row:nth(9)>div:nth(1)").find(".inner").text(),
approvalSample: box.find(".row:nth(10)>div:nth(1)").find(".inner").html(),
approvalResultType: box.find(".row:nth(10)>div:nth(3)").find(".inner").text()
},
feeInfo: {
isThereAFee: box.find(".row:nth(12)>div:nth(1)").find(".inner").text(),
isOnlinePaymentSupported: box.find(".row:nth(12)>div:nth(3)").find(".inner").text()
},
approvalInfo: {
authoritySource: box.find(".row:nth(14)>div:nth(1)").find(".inner").text(),
exerciseLevel: box.find(".row:nth(15)>div:nth(1)").find(".inner").text(),
implementingEntity: box.find(".row:nth(15)>div:nth(3)").find(".inner").text()
},
deliveryInfo: {
isLogisticsSupported: box.find(".row:nth(17)>div:nth(1)").find(".inner").text(),
deliveryTimeframe: box.find(".row:nth(17)>div:nth(3)").find(".inner").text(),
deliveryMethods: box.find(".row:nth(18)>div:nth(1)").find(".inner").text()
},
agentService: box.find(".row:nth(20)>div:nth(1)").find(".inner").text(),
otherInfo: {
departmentName: box.find(".row:nth(22)>div:nth(1)").find(".inner").text(),
matterType: box.find(".row:nth(22)>div:nth(3)").find(".inner").text(),
acceptingInstitution: box.find(".row:nth(23)>div:nth(1)").find(".inner").text(),
basicCode: box.find(".row:nth(24)>div:nth(1)").find(".inner").text(),
implementationCode: box.find(".row:nth(24)>div:nth(3)").find(".inner").text(),
scopeOfGeneralHandling: box.find(".row:nth(25)>div:nth(1)").find(".inner").text(),
documentType: box.find(".row:nth(25)>div:nth(3)").find(".inner").text(),
decisionMakingAuthority: box.find(".row:nth(26)>div:nth(1)").find(".inner").text(),
delegatedDepartment: box.find(".row:nth(26)>div:nth(3)").find(".inner").text(),
onlineProcessingDepth: box.find(".row:nth(27)>div:nth(1)").find(".inner").text(),
reviewType: box.find(".row:nth(27)>div:nth(3)").find(".inner").text(),
isItAvailableInTheGovernmentServiceHall: box.find(".row:nth(28)>div:nth(1)").find(".inner").text(),
isSelfServiceTerminalProcessingSupported: box.find(".row:nth(28)>div:nth(3)").find(".inner").text(),
isACommitmentSystemImplemented: box.find(".row:nth(29)>div:nth(1)").find(".inner").text(),
authorityAttribute: box.find(".row:nth(29)>div:nth(3)").find(".inner").text(),
isAppointmentBookingSupported: box.find(".row:nth(30)>div:nth(1)").find(".inner").text(),
isOnlineProcessingAvailable: box.find(".row:nth(30)>div:nth(3)").find(".inner").text(),
naturalPersonThemeClassification: box.find(".row:nth(31)>div:nth(1)").find(".inner").text(),
legalPersonThemeClassification: box.find(".row:nth(31)>div:nth(3)").find(".inner").text(),
rightsAndObligationsOfAdministrativeCounterparties: box.find(".row:nth(32)>div:nth(1)").find(".inner").text(),
applicableObjectDescription: box.find(".row:nth(33)>div:nth(1)").find(".inner").text(),
contentInvolved: box.find(".row:nth(34)>div:nth(1)").find(".inner").text()
}
};
}
//#endregion
//#region lib/routes/gov/hangzhou/zwfw.ts
const route = {
path: "/hangzhou/zwfw",
categories: ["government"],
example: "/gov/hangzhou/zwfw",
features: {
requireConfig: false,
requirePuppeteer: true,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["hangzhou.gov.cn/col/col1256349/index.html"] }],
name: "政务服务公开",
maintainers: ["flynncao"],
handler,
url: "hangzhou.gov.cn/col/col1256349/index.html"
};
async function handler() {
const host = "https://www.hangzhou.gov.cn/col/col1256349/index.html";
const response = await ofetch_default(host);
const browser = await puppeteer_default();
const link = host;
const $ = load(response.replace("<script type=\"text/xml\">", "").replace("<\/script>", "").replaceAll("<recordset>", "").replaceAll("</recordset>", "").replaceAll("<record>", "").replaceAll("</record>", "").replaceAll("<![CDATA[", "").replaceAll("]]>", ""));
const list = $("li.clearfix").toArray().map((item) => {
item = $(item);
const title = item.find("a").first().text();
const time = timezone(parseDate(item.find("span").first().text(), "YYYY-MM-DD"), 8);
const a = item.find("a").first().attr("href");
return {
title,
link: new URL(a, host).href,
pubDate: time
};
}).filter((item) => !item.title.includes("置顶"));
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const host$1 = new URL(item.link).hostname;
if (host$1 === "www.zjzwfw.gov.cn") {
const $$1 = load(await crawler(item, browser));
item.description = art(path.resolve(__dirname, "templates/jbxx-81ef584c.art"), analyzer($$1(".item-left .item .bg_box")));
item.author = "浙江政务服务网";
item.category = $$1("meta[name=\"ColumnType\"]").attr("content");
} else {
const $$1 = load((await got_default(item.link)).data);
if (host$1 === "police.hangzhou.gov.cn") {
item.description = $$1(".art-content .wz_con_content").html();
item.author = $$1("meta[name=\"ContentSource\"]").attr("content");
item.category = $$1("meta[name=\"ColumnType\"]").attr("content");
} else {
item.description = $$1(".article").html();
item.author = $$1("meta[name=\"ContentSource\"]").attr("content");
item.category = $$1("meta[name=\"ColumnType\"]").attr("content");
}
}
item.pubDate = $("meta[name=\"PubDate\"]").length ? timezone(parseDate($("meta[name=\"PubDate\"]").attr("content"), "YYYY-MM-DD HH:mm"), 8) : item.pubDate;
return item;
})));
await browser.close();
return {
allowEmpty: true,
title: "杭州市人民政府-政务服务公开",
link,
item: items
};
}
//#endregion
export { route };