diff --git a/docs/government.md b/docs/government.md index f77b30a92..8b466a663 100644 --- a/docs/government.md +++ b/docs/government.md @@ -16,6 +16,12 @@ pageClass: routes +## 澳门卫生局 + +### 最新消息 + + + ## 北京市卫生健康委员会 ### 新闻中心 diff --git a/lib/v2/ssm/maintainer.js b/lib/v2/ssm/maintainer.js new file mode 100644 index 000000000..89c40d4d5 --- /dev/null +++ b/lib/v2/ssm/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/news': ['Fatpandac'], +}; diff --git a/lib/v2/ssm/news.js b/lib/v2/ssm/news.js new file mode 100644 index 000000000..f3a0091c1 --- /dev/null +++ b/lib/v2/ssm/news.js @@ -0,0 +1,38 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const path = require('path'); +const { art } = require('@/utils/render'); + +const rootUrl = `https://www.ssm.gov.mo`; +const newsUrl = `${rootUrl}/apps1/content/ch/973/itemlist.aspx?defaultcss=false&dlimit=20&showdate=true&dorder=cridate%20desc,displaydate%20desc&withattach=true`; + +module.exports = async (ctx) => { + const response = await got.get(newsUrl); + const $ = cheerio.load(response.data); + const list = $('body > div > div > ul > li'); + + const item = list + .map((_, item) => { + const title = $(item).find('a').text(); + const link = $(item).find('a').attr('href'); + const pubDate = parseDate($(item).find('small').text().split(':')[1].trim(), 'DD/MM/YYYY'); + const desc = art(path.join(__dirname, 'templates/news.art'), { + link, + }); + + return { + title, + link, + description: desc, + pubDate, + }; + }) + .get(); + + ctx.state.data = { + title: '澳门卫生局-最新消息', + link: rootUrl, + item, + }; +}; diff --git a/lib/v2/ssm/radar.js b/lib/v2/ssm/radar.js new file mode 100644 index 000000000..57a032a59 --- /dev/null +++ b/lib/v2/ssm/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'ssm.gov.mo': { + _name: '澳门卫生局', + www: [ + { + title: '最新消息', + docs: 'https://docs.rsshub.app/government.html#ao-men-wei-sheng-ju-zui-xin-xiao-xi', + source: ['/', '/portal'], + target: '/ssm/news', + }, + ], + }, +}; diff --git a/lib/v2/ssm/router.js b/lib/v2/ssm/router.js new file mode 100644 index 000000000..69a5972f6 --- /dev/null +++ b/lib/v2/ssm/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/news', require('./news')); +}; diff --git a/lib/v2/ssm/templates/news.art b/lib/v2/ssm/templates/news.art new file mode 100644 index 000000000..053f7482e --- /dev/null +++ b/lib/v2/ssm/templates/news.art @@ -0,0 +1 @@ +