From aedc536fcb1cf3259058ed563cc39acbaa29ba69 Mon Sep 17 00:00:00 2001 From: KeiLongW Date: Tue, 15 Jun 2021 01:14:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20=E6=BE=B3=E9=96=80=E7=89=B9?= =?UTF-8?q?=E5=88=A5=E8=A1=8C=E6=94=BF=E5=8D=80=E6=94=BF=E5=BA=9C=E5=90=84?= =?UTF-8?q?=E5=85=AC=E5=85=B1=E9=83=A8=E9=96=80=E7=8D=8E=E5=8A=A9=E8=B2=B8?= =?UTF-8?q?=E5=AD=B8=E9=87=91=E6=9C=8D=E5=8B=99=E5=B9=B3=E5=8F=B0=20(#7547?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/other.md | 12 ++++++++ lib/router.js | 3 ++ lib/routes/macau-bolsas/index.js | 47 ++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 lib/routes/macau-bolsas/index.js 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, + }; +};