feat(route): add 台灣衛生福利部即時新聞澄清 (#8576)
This commit is contained in:
parent
7156aad182
commit
9e6cf26a6e
|
|
@ -234,6 +234,12 @@ pageClass: routes
|
|||
|
||||
<Route author="EsuRt" example="/gov/suzhou/doc" path="/gov/suzhou/doc"/>
|
||||
|
||||
## 台灣衛生福利部
|
||||
|
||||
### 即時新聞澄清
|
||||
|
||||
<Route author="nczitzk" example="/mohw/clarification" path="/mohw/clarification"/>
|
||||
|
||||
## 武汉东湖新技术开发区
|
||||
|
||||
### 新闻中心
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://www.mohw.gov.tw';
|
||||
const currentUrl = `${rootUrl}/lp-17-1.html`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
let items = $('.list01 a[title]')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: item.attr('href'),
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('article').html();
|
||||
item.pubDate = parseDate(content('meta[name="DC.Date"]').attr('datetime'));
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '即時新聞澄清 - 台灣衛生福利部',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/clarification': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'mohw.gov.tw': {
|
||||
_name: '台灣衛生福利部',
|
||||
'.': [
|
||||
{
|
||||
title: '即時新聞澄清',
|
||||
docs: 'https://docs.rsshub.app/government.html#tai-wan-wei-sheng-fu-li-bu-ji-shi-xin-wen-cheng-qing',
|
||||
source: ['/'],
|
||||
target: '/mohw/clarification',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/clarification', require('./clarification'));
|
||||
};
|
||||
Loading…
Reference in New Issue