feat: add route coronavirus/sg-moh (#3961)

This commit is contained in:
Gong Deli
2020-02-15 19:06:50 +08:00
committed by GitHub
parent baa63ecef4
commit c91095f469
3 changed files with 54 additions and 0 deletions

View File

@@ -430,6 +430,10 @@ type 为 all 时category 参数不支持 cost 和 free
| ---- | ---- | ---- | | ---- | ---- | ---- |
| ch | en | pt | | ch | en | pt |
### Singapore Ministry of Health - Past Updates on 2019-nCov Local Situation in Singapore
<Route author="Gnnng" example="/coronavirus/sg-moh" path="/coronavirus/sg-moh"/>
## 新趣集 ## 新趣集
> 官方 Feed 地址为: [https://xinquji.com/rss](https://xinquji.com/rss) > 官方 Feed 地址为: [https://xinquji.com/rss](https://xinquji.com/rss)

View File

@@ -2175,6 +2175,7 @@ router.get('/coronavirus/scmp', require('./routes/coronavirus/scmp'));
router.get('/coronavirus/nhc', require('./routes/coronavirus/nhc')); router.get('/coronavirus/nhc', require('./routes/coronavirus/nhc'));
router.get('/coronavirus/mogov-2019ncov/:lang', require('./routes/coronavirus/mogov-2019ncov')); router.get('/coronavirus/mogov-2019ncov/:lang', require('./routes/coronavirus/mogov-2019ncov'));
router.get('/coronavirus/qq/fact', require('./routes/tencent/factcheck')); router.get('/coronavirus/qq/fact', require('./routes/tencent/factcheck'));
router.get('/coronavirus/sg-moh', require('./routes/coronavirus/sg-moh'));
// 南京林业大学教务处 // 南京林业大学教务处
router.get('/njfu/jwc/:category?', require('./routes/universities/njfu/jwc')); router.get('/njfu/jwc/:category?', require('./routes/universities/njfu/jwc'));

View File

@@ -0,0 +1,49 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const dataUrl = 'https://www.moh.gov.sg/2019-ncov-wuhan/past-updates';
const response = await got({
method: 'get',
url: dataUrl,
});
const $ = cheerio.load(response.data);
const list = $('section.body-content div.sfContentBlock:nth-of-type(2) table tr').slice(1, 21);
const items = list
.filter((_, item) => {
item = $(item);
const dateRaw = item
.find('td:first-child')
.text()
.trim();
return dateRaw !== 'Date';
})
.map((_, item) => {
item = $(item);
const title = `${item
.find('a')
.first()
.text()}`;
const dateRaw = item
.find('td:first-child')
.text()
.trim();
const pubDate = Date.parse(dateRaw) && dateRaw;
const link = item.find('a').attr('href');
return {
title,
pubDate,
link,
};
})
.get();
ctx.state.data = {
title: 'Past Updates On 2019-NCOV Local Situation',
link: dataUrl,
description: 'Past Updates On 2019-NCOV Local Situation',
item: items,
};
};