mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-11 15:47:48 +08:00
@@ -2675,6 +2675,7 @@ 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="['文种分类。 国令; 国发; 国函; 国发明电; 国办发; 国办函; 国办发明电; 其他']" />
|
||||
|
||||
### 联合国
|
||||
|
||||
|
||||
@@ -1012,6 +1012,7 @@ 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('/xiaoheihe/user/:id', require('./routes/xiaoheihe/user'));
|
||||
|
||||
52
lib/routes/gov/zhengce/wenjian.js
Normal file
52
lib/routes/gov/zhengce/wenjian.js
Normal file
@@ -0,0 +1,52 @@
|
||||
const axios = require('../../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { pcodeJiguan } = ctx.params;
|
||||
const link = `http://sousuo.gov.cn/list.htm`;
|
||||
const res = await axios.get(link, {
|
||||
params: {
|
||||
n: 20,
|
||||
sort: 'pubtime',
|
||||
t: 'paper',
|
||||
pcodeJiguan: pcodeJiguan ? pcodeJiguan : '',
|
||||
},
|
||||
});
|
||||
const $list = cheerio.load(res.data);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `最新文件 - 中国政府网`,
|
||||
link,
|
||||
item: await Promise.all(
|
||||
$list('body > div.dataBox > table > tbody > tr')
|
||||
.slice(1)
|
||||
.map(async (_, el) => {
|
||||
const item = $list(el);
|
||||
|
||||
const number = item.find('td.info').next();
|
||||
const title = item.find('td.info > a');
|
||||
const href = title.attr('href');
|
||||
|
||||
const key = `gov_zhengce: ${href}`;
|
||||
let description;
|
||||
const value = await ctx.cache.get(key);
|
||||
|
||||
if (value) {
|
||||
description = value;
|
||||
} else {
|
||||
const contentData = await axios.get(href);
|
||||
const $content = cheerio.load(contentData.data);
|
||||
description = $content('#UCAP-CONTENT').html();
|
||||
ctx.cache.set(key, description, 24 * 60 * 60);
|
||||
}
|
||||
|
||||
return {
|
||||
title: number.text() + ' | ' + title.text(),
|
||||
description,
|
||||
link: href,
|
||||
};
|
||||
})
|
||||
.get()
|
||||
),
|
||||
};
|
||||
};
|
||||
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
|
||||
const $el = $list(el);
|
||||
const $a = $el.find('h4 a');
|
||||
const href = $a.attr('href');
|
||||
const key = `zuixin_zhengce: ${href}`;
|
||||
const key = `gov_zhengce: ${href}`;
|
||||
let description;
|
||||
const value = await ctx.cache.get(key);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user