diff --git a/docs/README.md b/docs/README.md index 2716eaa55d..8b47eac449 100755 --- a/docs/README.md +++ b/docs/README.md @@ -2693,6 +2693,10 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 +### 中华人民共和国生态环境部 + + + ### 联合国 diff --git a/lib/router.js b/lib/router.js index 4be7c2d95f..9859314778 100755 --- a/lib/router.js +++ b/lib/router.js @@ -1019,6 +1019,9 @@ router.get('/cyzone/author/:id', require('./routes/cyzone/author')); router.get('/gov/zhengce/zuixin', require('./routes/gov/zhengce/zuixin')); router.get('/gov/zhengce/wenjian/:pcodeJiguan?', require('./routes/gov/zhengce/wenjian')); +// 中华人民共和国生态环境部 +router.get('/gov/mee/gs', require('./routes/gov/mee/gs')); + // 小黑盒 router.get('/xiaoheihe/user/:id', require('./routes/xiaoheihe/user')); diff --git a/lib/routes/gov/mee/gs.js b/lib/routes/gov/mee/gs.js new file mode 100644 index 0000000000..f571f5efdd --- /dev/null +++ b/lib/routes/gov/mee/gs.js @@ -0,0 +1,54 @@ +const axios = require('../../../utils/axios'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const linkBase = `http://www.mee.gov.cn/xxgk/gs/gsq/`; + const listData = await axios.get(linkBase); + const $ = cheerio.load(listData.data); + ctx.state.data = { + title: `公示 - 中华人民共和国生态环境部`, + link: linkBase, + item: await Promise.all( + $('.main .main_top li') + .map(async (_, el) => { + const $el = $(el); + const $a = $el.find('>a'); + const href = $a.attr('href'); + const key = `gov_gs: ${href}`; + let description; + const value = await ctx.cache.get(key); + + // 移除 href 中的 ./,并且拼接原来的 url + const link = `${linkBase}${href.slice(2)}`; + + if (value) { + description = value; + } else { + const contentData = await axios.get(link); + const $content = cheerio.load(contentData.data); + description = $content('.TRS_Editor').html(); + ctx.cache.set(key, description, 24 * 60 * 60); + } + + const title = $a.text(); + + // 获取 date + const pubDate = new Date( + $el + .find('.shover') + .first() + .text() + .match(/\d{4}-\d{2}-\d{2}/) + ).toUTCString(); + + return { + title, + description, + link, + pubDate, + }; + }) + .get() + ), + }; +};