feat(route): add route for 浦东新区-政务公开 (#17115)
* newly add 浦东新区-政务公开 route * newly add 浦东新区-政务公开 route * Update zwgk.ts * newly add 浦东新区-政务公开 route update * newly add 浦东新区-政务公开 route update * newly add 浦东新区-政务公开 route update * newly add 浦东新区-政务公开 route update * Update lib/routes/gov/pudong/zwgk.ts ---------
This commit is contained in:
parent
1d77ba3785
commit
2fee4250fb
|
|
@ -0,0 +1,65 @@
|
|||
import { Route } from '@/types';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date'; // 解析日期的工具函数
|
||||
import cache from '@/utils/cache';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/pudong/zwgk',
|
||||
categories: ['government'],
|
||||
example: '/gov/pudong/zwgk',
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
radar: [
|
||||
{
|
||||
source: ['www.pudong.gov.cn/zwgk/zxxxgk/index.html'],
|
||||
target: '/pudong/zwgk',
|
||||
},
|
||||
],
|
||||
name: '政务公开-浦东新区',
|
||||
maintainers: ['himingway'],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler() {
|
||||
const response = await ofetch('https://www.pudong.gov.cn/zwgk-search-front/api/data/affair', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
channelList: ['5144'],
|
||||
pageSize: 20,
|
||||
},
|
||||
});
|
||||
const data = response.data.list;
|
||||
|
||||
const list = data.map((item) => ({
|
||||
title: item.title,
|
||||
link: item.url,
|
||||
pubDate: parseDate(item.display_date),
|
||||
}));
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const response = await ofetch(item.link);
|
||||
const $ = load(response);
|
||||
item.description = $('#ivs_content').first().html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
return {
|
||||
// 源标题
|
||||
title: '信息公开_政务公开-上海市浦东新区门户网站',
|
||||
// 源链接
|
||||
link: 'https://www.pudong.gov.cn/zwgk/zxxxgk/index.html',
|
||||
// 源文章
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
Loading…
Reference in New Issue