feat(route): 新增江苏文化和旅游局审批公告 (#14978)

* 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>
This commit is contained in:
GideonSenku
2024-04-15 23:01:48 +08:00
committed by GitHub
co-authored by pull[bot]
parent cbf59e0c74
commit afc5e3396a
2 changed files with 108 additions and 0 deletions
+99
View File
@@ -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,
};
}
@@ -0,0 +1,9 @@
<text>许可日期:{{ dateText }} </text>
<br>
<text>行政名称:{{ hostingUnit }} </text>
<br>
<text>许可编号:{{ licenseNumber }} </text>
<br>
<text>项目名称:{{ performanceName }} </text>
<br>
<text>许可内容:{{ performanceContent }} </text>