mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-11 07:40:26 +08:00
🐰 Add 中华人民共和国生态环境部公告 (#1707)
This commit is contained in:
@@ -2693,6 +2693,10 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
|
||||
<route name="最新政策" author="SettingDust" example="/gov/zhengce/zuixin" path="/gov/zhengce/zuixin"/>
|
||||
<route name="最新文件" author="ciaranchen" example="/gov/zhengce/wenjian" path="/gov/zhengce/wenjian/:pcodeJiguan?" :paramsDesc="['文种分类。 国令; 国发; 国函; 国发明电; 国办发; 国办函; 国办发明电; 其他']" />
|
||||
|
||||
### 中华人民共和国生态环境部
|
||||
|
||||
<route name="公示" author="billyct" example="/gov/mee/gs" path="/gov/mee/gs"/>
|
||||
|
||||
### 联合国
|
||||
|
||||
<route name="安理会否决了决议" author="HenryQW" example="/un/scveto" path="/un/scveto"/>
|
||||
|
||||
@@ -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'));
|
||||
|
||||
|
||||
54
lib/routes/gov/mee/gs.js
Normal file
54
lib/routes/gov/mee/gs.js
Normal file
@@ -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()
|
||||
),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user