From 98ea099caa44296237f7723e86beee5142f18a15 Mon Sep 17 00:00:00 2001 From: KeiLongW Date: Sat, 1 Feb 2020 17:26:46 +0800 Subject: [PATCH] feat: add macau government wuhan infection news (#3844) --- docs/en/other.md | 10 ++++ docs/other.md | 10 ++++ lib/router.js | 1 + lib/routes/coronavirus/mogov-2019ncov.js | 64 ++++++++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 lib/routes/coronavirus/mogov-2019ncov.js diff --git a/docs/en/other.md b/docs/en/other.md index 1c00c48518..f3bda48a4a 100644 --- a/docs/en/other.md +++ b/docs/en/other.md @@ -151,3 +151,13 @@ Type ### South China Morning Post - China coronavirus outbreak + +### Macao Pagina Electrónica Especial Contra Epidemias: What’s New + +Official Website: [https://www.ssm.gov.mo/apps1/PreventWuhanInfection/en.aspx](https://www.ssm.gov.mo/apps1/PreventWuhanInfection/en.aspx) + + + +| Chinese | English | Portuguese | +| ------- | ------- | ---------- | +| ch | en | pt | diff --git a/docs/other.md b/docs/other.md index 2e5a1611f3..e4ca5d21d9 100644 --- a/docs/other.md +++ b/docs/other.md @@ -410,6 +410,16 @@ type 为 all 时,category 参数不支持 cost 和 free +### 澳門特別行政區政府 抗疫專頁:最新消息 + +官方網址:[https://www.ssm.gov.mo/apps1/PreventWuhanInfection/ch.aspx](https://www.ssm.gov.mo/apps1/PreventWuhanInfection/ch.aspx) + + + +| 中文 | 英文 | 葡文 | +| ---- | ---- | ---- | +| ch | en | pt | + ## 新趣集 > 官方 Feed 地址为: [https://xinquji.com/rss](https://xinquji.com/rss) diff --git a/lib/router.js b/lib/router.js index af89f28484..aa77861d44 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2161,6 +2161,7 @@ router.get('/coronavirus/dxy/data/:province?/:city?', require('./routes/coronavi router.get('/coronavirus/dxy', require('./routes/coronavirus/dxy')); router.get('/coronavirus/scmp', require('./routes/coronavirus/scmp')); router.get('/coronavirus/nhc', require('./routes/coronavirus/nhc')); +router.get('/coronavirus/mogov-2019ncov/:lang', require('./routes/coronavirus/mogov-2019ncov')); // 南京林业大学教务处 router.get('/njfu/jwc/:category?', require('./routes/universities/njfu/jwc')); diff --git a/lib/routes/coronavirus/mogov-2019ncov.js b/lib/routes/coronavirus/mogov-2019ncov.js new file mode 100644 index 0000000000..b299dca3ce --- /dev/null +++ b/lib/routes/coronavirus/mogov-2019ncov.js @@ -0,0 +1,64 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const FormData = require('form-data'); + +module.exports = async (ctx) => { + const language = ctx.params.lang.toLowerCase(); + + const dataUrl = `https://www.ssm.gov.mo/apps1/apps/webpage2020/wpg/gcsnewssc_body.aspx`; + const form = new FormData(); + form.append('pg', '0'); + form.append('lang', language); + + const dateTextMapping = { + ch: '日期 : ', + pt: 'Date : ', + en: 'Date : ', + }; + + const response = await got({ + method: 'post', + url: dataUrl, + data: form, + }); + const $ = cheerio.load(response.data); + const items = $('div.col-xs-12') + .map((i, elem) => { + const $item = cheerio.load(elem); + const title = $item('div > span.padding-sm > b > a:first-child').text(); + const $descriptionWrapper = cheerio.load('
'); + $descriptionWrapper('div').append( + $item('div.clearfix') + .first() + .nextAll() + ); + const description = $descriptionWrapper.html(); + const pubDate = new Date( + $descriptionWrapper('div.padding-sm.fontsize-sm') + .text() + .replace(dateTextMapping[language], '') + ' +8' + ).toUTCString(); + const link = $item('div > span.padding-sm > b > a:first-child').attr('href'); + return { + title, + description, + pubDate, + link, + }; + }) + .get(); + + const titleMapping = { + ch: '澳門特別行政區政府 抗疫專頁:最新消息', + pt: 'Macau Pagina Electrónica Especial Contra Epidemias: Notícias', + en: 'Macao Pagina Electrónica Especial Contra Epidemias: What’s New', + }; + const sourceLink = `https://www.ssm.gov.mo/apps1/PreventWuhanInfection/${language}.aspx`; + + ctx.state.data = { + title: titleMapping[language], + link: sourceLink, + description: titleMapping[language], + item: items, + }; +};