feat(route): moj aac (#10168)
This commit is contained in:
parent
dde57522ae
commit
b4d37f9837
|
|
@ -522,6 +522,18 @@ pageClass: routes
|
|||
|
||||
</Route>
|
||||
|
||||
## 台灣法務部廉政署
|
||||
|
||||
### 最新消息
|
||||
|
||||
<Route author="TonyRL" example="/gov/moj/aac/news" path="/gov/moj/aac/news/:type?" :paramsDesc="['資料大類,留空為全部']">
|
||||
|
||||
| 全部 | 其他 | 採購公告 | 新聞稿 | 肅貪 | 預防 | 綜合 | 防疫專區 |
|
||||
| -- | -- | ---- | --- | -- | -- | -- | ---- |
|
||||
| | 02 | 01 | 06 | 05 | 04 | 03 | 99 |
|
||||
|
||||
</Route>
|
||||
|
||||
## 台灣衛生福利部
|
||||
|
||||
### 即時新聞澄清
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ module.exports = {
|
|||
'/miit/wjgs': ['Yoge-Code'],
|
||||
'/miit/zcjd': ['Yoge-Code'],
|
||||
'/moe/:type': ['Crawler995'],
|
||||
'/moj/aac/news/:type?': ['TonyRL'],
|
||||
'/nmpa/:path+': ['TonyRL'],
|
||||
'/nrta/news/:category?': ['yuxinliu-alex'],
|
||||
'/nsfc/news/:type?': ['Derekmini', 'nczitzk'],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const baseUrl = 'https://www.aac.moj.gov.tw';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { type } = ctx.params;
|
||||
const url = `${baseUrl}/7204/7246/?Page=1&PageSize=40${type ? `&type=${type}` : ''}`;
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
$('.num').remove();
|
||||
const list = $('.list ul li a')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const isDownload = /檔案下載/.test(item.attr('title'));
|
||||
const title = isDownload ? item.text().trim() : item.attr('title');
|
||||
return {
|
||||
title,
|
||||
link: new URL(item.attr('href'), baseUrl).href,
|
||||
isDownload,
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
if (!item.isDownload) {
|
||||
const response = await got(item.link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
item.pubDate = timezone(parseDate($('.info time').attr('datetime'), 'YYYY-MM-DD HH:mm:ss'), +8);
|
||||
$('.info, button').remove();
|
||||
item.description = $('.cp').html() + ($('.lightbox_slider').length ? $('.lightbox_slider').html() : '') + ($('.file_download').length ? $('.file_download').html() : '');
|
||||
}
|
||||
delete item.isDownload;
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('head title').text(),
|
||||
link: url,
|
||||
item: items,
|
||||
language: 'zh-TW',
|
||||
};
|
||||
};
|
||||
|
|
@ -450,6 +450,17 @@ module.exports = {
|
|||
},
|
||||
],
|
||||
},
|
||||
'moj.gov.tw': {
|
||||
_name: '台灣法務部廉政署',
|
||||
'www.aac': [
|
||||
{
|
||||
title: '最新消息',
|
||||
docs: 'https://docs.rsshub.app/government.html#zhong-hua-ren-min-gong-he-guo-jiao-yu-bu',
|
||||
source: ['/7204/7246/'],
|
||||
target: (_params, url) => `/gov/moj/aac/news${new URL(url).searchParams.has('type') ? '/' + new URL(url).searchParams.get('type') : ''}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
'nmpa.gov.cn': {
|
||||
_name: '国家药品监督管理局',
|
||||
'.': [
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ module.exports = function (router) {
|
|||
router.get('/miit/wjgs', require('./miit/wjgs'));
|
||||
router.get('/miit/zcjd', require('./miit/zcjd'));
|
||||
router.get('/moe/:type', require('./moe/moe'));
|
||||
router.get('/moj/aac/news/:type?', require('./moj/aac/news'));
|
||||
router.get(/\/nmpa\/([\w][\w/]+)?/, require('./nmpa/generic'));
|
||||
router.get('/nrta/news/:category?', require('./nrta/news'));
|
||||
router.get('/nsfc/news/:type?', require('./nsfc'));
|
||||
|
|
|
|||
Loading…
Reference in New Issue