From afc5e3396a987e7a8ea74ab589eba769d9dd926b Mon Sep 17 00:00:00 2001
From: GideonSenku <39037656+GideonSenku@users.noreply.github.com>
Date: Mon, 15 Apr 2024 23:01:48 +0800
Subject: [PATCH] =?UTF-8?q?feat(route):=20=E6=96=B0=E5=A2=9E=E6=B1=9F?=
=?UTF-8?q?=E8=8B=8F=E6=96=87=E5=8C=96=E5=92=8C=E6=97=85=E6=B8=B8=E5=B1=80?=
=?UTF-8?q?=E5=AE=A1=E6=89=B9=E5=85=AC=E5=91=8A=20(#14978)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat(route): add jiangsu wlt
* fix: link url
* fix: rule
* fix: node ptah
---------
Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com>
---
lib/routes/gov/jiangsu/wlt/index.ts | 99 ++++++++++++++++++++
lib/routes/gov/jiangsu/wlt/templates/wlt.art | 9 ++
2 files changed, 108 insertions(+)
create mode 100644 lib/routes/gov/jiangsu/wlt/index.ts
create mode 100644 lib/routes/gov/jiangsu/wlt/templates/wlt.art
diff --git a/lib/routes/gov/jiangsu/wlt/index.ts b/lib/routes/gov/jiangsu/wlt/index.ts
new file mode 100644
index 000000000..9bbcd0159
--- /dev/null
+++ b/lib/routes/gov/jiangsu/wlt/index.ts
@@ -0,0 +1,99 @@
+import { Route } from '@/types';
+import { getCurrentPath } from '@/utils/helpers';
+
+import cache from '@/utils/cache';
+import got from '@/utils/got';
+import { load } from 'cheerio';
+import { parseDate } from '@/utils/parse-date';
+import { art } from '@/utils/render';
+import path from 'node:path';
+
+const __dirname = getCurrentPath(import.meta.url);
+
+export const route: Route = {
+ path: '/jiangsu/wlt/:page?',
+ categories: ['government'],
+ example: '/gov/jiangsu/wlt',
+ parameters: { page: '页数,默认第 1 页' },
+ features: {
+ requireConfig: false,
+ requirePuppeteer: false,
+ antiCrawler: false,
+ supportBT: false,
+ supportPodcast: false,
+ supportScihub: false,
+ },
+ radar: [
+ {
+ source: ['wlt.jiangsu.gov.cn/'],
+ target: '/jiangsu/wlt',
+ },
+ ],
+ name: '江苏文旅局审批公告',
+ maintainers: ['GideonSenku'],
+ handler,
+ url: 'wlt.jiangsu.gov.cn/',
+};
+
+async function handler(ctx) {
+ const baseUrl = 'http://58.213.82.179:18080/jsswlt_sgs/front';
+ const currentUrl = `${baseUrl}/list.do`;
+ const page = ctx.req.param('page') ?? 1;
+ const searchParams = {
+ type: 0,
+ pageNo0: page,
+ };
+ const response = await got({
+ method: 'get',
+ url: currentUrl,
+ searchParams,
+ });
+
+ const $ = load(response.data);
+ const list = $('.tg_tb1')
+ .map((_, item) => {
+ const i = $(item);
+ const id = i.prop('onclick').match(/openDetail\('(\d+)'\)/)?.[1] || '';
+ return {
+ title: i.text(),
+ link: id ? `${baseUrl}/detail.do?iid=${id}` : '',
+ description: '',
+ pubDate: '',
+ };
+ })
+ .get()
+ .filter((e) => e.link);
+ const items = await Promise.all(
+ list.map((item) =>
+ cache.tryGet(item.link, async () => {
+ const detailResponse = await got({
+ method: 'get',
+ url: item.link,
+ });
+ const $ = load(detailResponse.data);
+ const dateText = $('td:contains("许可决定日期")').next().text().trim();
+ const hostingUnit = $('td:contains("行政相对人名称")').next().text().trim();
+ const licenseNumber = $('td:contains("行政许可决定文书号")').next().text().trim();
+ const performanceName = $('td:contains("项目名称")').next().text().trim();
+ const performanceContent = $('td:contains("许可内容")').next().text().trim();
+
+ item.description = art(path.join(__dirname, './templates/wlt.art'), {
+ dateText,
+ hostingUnit,
+ licenseNumber,
+ performanceName,
+ performanceContent,
+ });
+ item.pubDate = parseDate(dateText);
+
+ return item;
+ })
+ )
+ );
+
+ return {
+ title: $('title').text(),
+ link: currentUrl,
+ item: items,
+ };
+}
diff --git a/lib/routes/gov/jiangsu/wlt/templates/wlt.art b/lib/routes/gov/jiangsu/wlt/templates/wlt.art
new file mode 100644
index 000000000..b39127372
--- /dev/null
+++ b/lib/routes/gov/jiangsu/wlt/templates/wlt.art
@@ -0,0 +1,9 @@
+许可日期:{{ dateText }}
+
+行政名称:{{ hostingUnit }}
+
+许可编号:{{ licenseNumber }}
+
+项目名称:{{ performanceName }}
+
+许可内容:{{ performanceContent }}