diff --git a/docs/government.md b/docs/government.md index 9be177583..72896876f 100644 --- a/docs/government.md +++ b/docs/government.md @@ -375,6 +375,12 @@ pageClass: routes +## 中华人民共和国住房和城乡建设部 + +### 政策发布 + + + ## 中央纪委国家监委 ### 审查调查 diff --git a/lib/router.js b/lib/router.js index 511128db1..1ac64996a 100755 --- a/lib/router.js +++ b/lib/router.js @@ -1172,6 +1172,9 @@ router.get('/gov/moe/:type', require('./routes/gov/moe/moe')); // 中华人民共和国外交部 router.get('/gov/fmprc/fyrbt', require('./routes/gov/fmprc/fyrbt')); +// 中华人民共和国住房和城乡建设部 +router.get('/gov/mohurd/policy', require('./routes/gov/mohurd/policy')); + // 国家新闻出版广电总局 router.get('/gov/sapprft/approval/:channel/:detail?', require('./routes/gov/sapprft/7026')); diff --git a/lib/routes/gov/mohurd/policy.js b/lib/routes/gov/mohurd/policy.js new file mode 100644 index 000000000..946f3b8e1 --- /dev/null +++ b/lib/routes/gov/mohurd/policy.js @@ -0,0 +1,40 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const link = `http://www.mohurd.gov.cn/wjfb/index.html`; + const response = await got({ method: 'get', url: link }); + + const $ = cheerio.load(response.data); + const list = $('body table tbody tr') + .eq(3) + .find('td table tbody tr') + .eq(2) + .find('td table tbody tr') + .map((_, item) => { + const a = $(item).find('a'); + const subtitle = $(item).find('td').eq(2).text(); + return { + title: a.text() + (subtitle === '' ? '' : ' - ' + subtitle), + link: a.attr('href'), + pubDate: new Date($(item).find('td').eq(3).text().substr(1, 10) + ' GMT+8').toUTCString(), + }; + }) + .get(); + + ctx.state.data = { + title: '中华人民共和国住房和城乡建设部 - 政策发布', + link: link, + item: await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ method: 'get', url: item.link }); + const content = cheerio.load(detailResponse.data); + item.description = content('table[bgcolor="#ffffff"]').html(); + return item; + }) + ) + ), + }; +};