mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
feat: add sapprft (#3739)
This commit is contained in:
@@ -4,6 +4,27 @@ pageClass: routes
|
|||||||
|
|
||||||
# 政务消息
|
# 政务消息
|
||||||
|
|
||||||
|
## 国家新闻出版广电总局
|
||||||
|
|
||||||
|
### 游戏审批结果
|
||||||
|
|
||||||
|
<Route author="y2361547758" example="/gov/sapprft/approval/domesticnetgame/2020年1月" path="/gov/sapprft/approval/:channel/:detail?" :paramsDesc="['栏目名', '标题关键字']">
|
||||||
|
|
||||||
|
| 栏目 | channel |
|
||||||
|
| :------------------: | :---------------: |
|
||||||
|
| 进口网络游戏审批信息 | importednetgame |
|
||||||
|
| 进口电子游戏审批信息 | importedvideogame |
|
||||||
|
| 国产网络游戏审批信息 | domesticnetgame |
|
||||||
|
| 游戏审批变更信息 | gamechange |
|
||||||
|
|
||||||
|
| 描述 | detail |
|
||||||
|
| :------------------------------------: | :--------------: |
|
||||||
|
| 留空,返回栏目所有文章 | |
|
||||||
|
| new,返回栏目第一篇文章内容 | new |
|
||||||
|
| 某个文章标题的一部分,返回这篇文章内容 | 例:2020 年 1 月 |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
## 联合国
|
## 联合国
|
||||||
|
|
||||||
### 安理会否决了决议
|
### 安理会否决了决议
|
||||||
|
|||||||
@@ -1120,6 +1120,9 @@ router.get('/gov/mee/gs', require('./routes/gov/mee/gs'));
|
|||||||
// 中华人民共和国外交部
|
// 中华人民共和国外交部
|
||||||
router.get('/gov/fmprc/fyrbt', require('./routes/gov/fmprc/fyrbt'));
|
router.get('/gov/fmprc/fyrbt', require('./routes/gov/fmprc/fyrbt'));
|
||||||
|
|
||||||
|
// 国家新闻出版广电总局
|
||||||
|
router.get('/gov/sapprft/approval/:channel/:detail?', require('./routes/gov/sapprft/7026'));
|
||||||
|
|
||||||
// 小黑盒
|
// 小黑盒
|
||||||
router.get('/xiaoheihe/user/:id', require('./routes/xiaoheihe/user'));
|
router.get('/xiaoheihe/user/:id', require('./routes/xiaoheihe/user'));
|
||||||
router.get('/xiaoheihe/news', require('./routes/xiaoheihe/news'));
|
router.get('/xiaoheihe/news', require('./routes/xiaoheihe/news'));
|
||||||
|
|||||||
119
lib/routes/gov/sapprft/7026.js
Normal file
119
lib/routes/gov/sapprft/7026.js
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const date = require('@/utils/date');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const { channel, detail } = ctx.params;
|
||||||
|
let id = '';
|
||||||
|
switch (channel) {
|
||||||
|
case 'importednetgame':
|
||||||
|
id = 7027;
|
||||||
|
break;
|
||||||
|
case 'importedvideogame':
|
||||||
|
id = 7028;
|
||||||
|
break;
|
||||||
|
case 'domesticnetgame':
|
||||||
|
id = 7029;
|
||||||
|
break;
|
||||||
|
case 'gamechange':
|
||||||
|
id = 11083;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ctx.throw(404, 'Cannot find page');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const host = `http://www.sapprft.gov.cn`;
|
||||||
|
const link = host + `/sapprft/channels/` + id.toString() + `.shtml`;
|
||||||
|
const listData = await got.get(link + '?' + new Date().getTime()); // 避免CDN缓存
|
||||||
|
const $ = cheerio.load(listData.data);
|
||||||
|
const target = $('.jar2l_list ul li');
|
||||||
|
let url = '';
|
||||||
|
for (const i in target) {
|
||||||
|
const item = $(target[i]).find('a');
|
||||||
|
if (~item.text().search(detail) || detail === 'new') {
|
||||||
|
url = host + item.attr('href');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!detail || url === '') {
|
||||||
|
ctx.state.data = {
|
||||||
|
title: '国家新闻出版广电总局 - ' + $('.jar2l_tname').text(),
|
||||||
|
link: link,
|
||||||
|
item: await Promise.all(
|
||||||
|
target
|
||||||
|
.map(async (index, item) => {
|
||||||
|
item = $(item);
|
||||||
|
const contenlUrl = host + item.find('a').attr('href');
|
||||||
|
const description = await ctx.cache.tryGet(contenlUrl, async () => {
|
||||||
|
const fullText = await got.get(contenlUrl);
|
||||||
|
const $$ = cheerio.load(fullText.data);
|
||||||
|
let fullTextData = '';
|
||||||
|
$$('.jar2_editor table tbody tr')
|
||||||
|
.slice(1)
|
||||||
|
.each((index, item) => {
|
||||||
|
item = $$(item).find('td');
|
||||||
|
fullTextData +=
|
||||||
|
$$(item[0])
|
||||||
|
.text()
|
||||||
|
.trim() + ' | ';
|
||||||
|
});
|
||||||
|
fullTextData = '| ' + fullTextData;
|
||||||
|
return fullTextData;
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
title: item.find('a').text(),
|
||||||
|
description: description,
|
||||||
|
pubDate: date(item.find('span').text()),
|
||||||
|
link: contenlUrl,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get()
|
||||||
|
),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const fullText = await got.get(url + '?' + new Date().getTime()); // 避免CDN缓存
|
||||||
|
const $$ = cheerio.load(fullText.data);
|
||||||
|
const list = $$('.jar2_editor table tbody tr');
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: '国家新闻出版广电总局 - ' + $('.jar2l_tname').text() + ' - ' + $$('.jar2_conT').text(),
|
||||||
|
link: url,
|
||||||
|
item: await Promise.all(
|
||||||
|
list
|
||||||
|
.slice(1)
|
||||||
|
.map(async (index, item) => {
|
||||||
|
item = $$(item).find('td');
|
||||||
|
return {
|
||||||
|
title: $$(item[0])
|
||||||
|
.text()
|
||||||
|
.trim(),
|
||||||
|
category: $$(item[1])
|
||||||
|
.text()
|
||||||
|
.trim(),
|
||||||
|
description: $$(item[4])
|
||||||
|
.text()
|
||||||
|
.trim(),
|
||||||
|
author:
|
||||||
|
$$(item[2])
|
||||||
|
.text()
|
||||||
|
.trim() +
|
||||||
|
' | ' +
|
||||||
|
$$(item[3])
|
||||||
|
.text()
|
||||||
|
.trim(),
|
||||||
|
pubDate: date(
|
||||||
|
$$(item[6])
|
||||||
|
.text()
|
||||||
|
.trim()
|
||||||
|
),
|
||||||
|
guid: $$(item[5])
|
||||||
|
.text()
|
||||||
|
.trim(),
|
||||||
|
link: url,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get()
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user