diff --git a/docs/other.md b/docs/other.md index 1a444879dc..ab2d788a0c 100644 --- a/docs/other.md +++ b/docs/other.md @@ -973,3 +973,15 @@ type 为 all 时,category 参数不支持 cost 和 free ### はてな匿名ダイアリー - 人気記事アーカイブ + +### 澳門特別行政區政府各公共部門獎助貸學金服務平台 + +官方網址: + + + +| 中文 | 葡文 | +| ---- | ---- | +| ch | pt | + + diff --git a/lib/router.js b/lib/router.js index 284da22cff..d9a6de415f 100644 --- a/lib/router.js +++ b/lib/router.js @@ -4103,4 +4103,7 @@ router.get('/hainanu/ssszs', require('./routes/hainanu/ssszs')); // 游戏年轮 router.get('/bibgame/:category?/:type?', require('./routes/bibgame/category')); +// 澳門特別行政區政府各公共部門獎助貸學金服務平台 +router.get('/macau-bolsas/:lang?', require('./routes/macau-bolsas/index')); + module.exports = router; diff --git a/lib/routes/macau-bolsas/index.js b/lib/routes/macau-bolsas/index.js new file mode 100644 index 0000000000..f436703057 --- /dev/null +++ b/lib/routes/macau-bolsas/index.js @@ -0,0 +1,47 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const lang = ctx.params.lang; + const url = `https://www.bolsas.gov.mo/${lang === 'pt' ? lang : ''}`; + const response = await got({ + method: 'get', + url: url, + }); + const $Wrapper = cheerio.load(response.data); + const liItems = $Wrapper('ul.news-list li'); + const items = await Promise.all( + liItems && + liItems + .map(async (_, item) => { + const $item = $Wrapper(item); + const $newsItem = $item.find('.news-item'); + const bureau = $newsItem.find('.label').text(); + const title = $newsItem.find('.title').text(); + const link = $newsItem.find('.title').attr('href'); + const pubDate = new Date($item.find('.date').text() + 'T00:00:00+0800'); + const description = await ctx.cache.tryGet(link, async () => { + const response = await got({ + method: 'get', + url: link, + }); + const $ = cheerio.load(response.data); + return $('.news-content').html(); + }); + return Promise.resolve({ + title: `[${bureau}] ${title}`, + link, + description, + pubDate, + }); + }) + .get() + ); + + ctx.state.data = { + title: '澳門特別行政區政府各公共部門獎助貸學金服務平台', + link: url, + description: '澳門特別行政區政府各公共部門獎助貸學金服務平台', + item: items, + }; +};