rsshub
Version:
Make RSS Great Again!
95 lines (93 loc) • 3.24 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 { t as timezone } from "./timezone-D8cuwzTY.mjs";
import { load } from "cheerio";
//#region lib/routes/gov/moa/szcpxx.ts
const handler = async (ctx) => {
const limit = ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit"), 10) : 6;
const currentUrl = new URL(`ztzl/szcpxx/zyzc/index.htm`, "http://www.moa.gov.cn").href;
const { data: response } = await got_default(currentUrl);
const $ = load(response);
const language = $("html").prop("lang");
let items = $("div.ztst_list_contBox_inner ul li").slice(0, limit).toArray().map((item) => {
item = $(item);
const a = item.find("a.content");
return {
title: a.prop("title"),
pubDate: parseDate(item.find("div.pubTime").text().split(/:/).pop(), "YYYY.MM.DD"),
link: new URL(a.prop("href"), currentUrl).href,
language
};
});
items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => {
const { data: detailResponse } = await got_default(item.link);
const $$ = load(detailResponse);
const title$1 = $$("h2.xxgk_title, h1.bjjMTitle").text();
const description = $$("div.gsj_htmlcon_bot, div.TRS_Editor").html();
const guid = `moa-${$$("meta[name=\"contentid\"]").prop("content")}`;
item.title = title$1;
item.description = description;
item.pubDate = timezone(parseDate($$("meta[name=\"PubDate\"]").prop("content")), 8);
item.category = [...new Set([
$$("meta[name=\"SiteName\"]").prop("content"),
$$("meta[name=\"ColumnName\"]").prop("content"),
$$("meta[name=\"ColumnType\"]").prop("content"),
$$("meta[name=\"ContentSource\"]").prop("content"),
$$("meta[name=\"Keywords\"]").prop("content")
])].filter(Boolean);
item.author = $$("meta[name=\"Author\"]").prop("content") || $$("meta[name=\"source\"]").prop("content");
item.guid = guid;
item.id = guid;
item.content = {
html: description,
text: $$("div.gsj_htmlcon_bot, div.TRS_Editor").text()
};
item.language = language;
return item;
})));
const title = `${$("title").text()} - ${$("li.now").text()}`;
const image = new URL($("img.leftLogo").prop("src"), currentUrl).href;
return {
title,
description: title,
link: currentUrl,
item: items,
allowEmpty: true,
image,
author: "中华人民共和国农业农村部",
language
};
};
const route = {
path: "/moa/szcpxx",
name: "中华人民共和国农业农村部生猪专题重要政策",
url: "www.moa.gov.cn",
maintainers: ["nczitzk"],
handler,
example: "/gov/moa/szcpxx",
parameters: void 0,
description: void 0,
categories: ["government"],
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportRadar: true,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{
source: ["www.moa.gov.cn/ztzl/szcpxx/zyzc/index.htm"],
target: "/moa/szcpxx"
}]
};
//#endregion
export { handler, route };