mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): 国家广播电视总局 (#9566)
* feat(route): 国家广播电视总局 * move the nrta to lib\v2\gov * fix: feed link * fix: radar * fix: radar Co-authored-by: alex <yuxin2@mgtv.com>
This commit is contained in:
@@ -156,6 +156,17 @@ pageClass: routes
|
||||
|
||||
<Route author="Fatpandac" example="/gov/huizhou/zwgk/jgdt" path="/gov/huizhou/zwgk/:category?" :paramsDesc="['资讯类别,可以从网址中得到,默认为政务要闻']"/>
|
||||
|
||||
## 国家广播电视总局
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="yuxinliu-alex" example="/gov/nrta/news" path="/gov/nrta/news/:category?" :paramsDesc="['资讯类别, 可从地址中获取,默认为总局要闻']"/>
|
||||
|
||||
| 总局要闻 | 公告公示 | 工作动态 | 其他 |
|
||||
|:----:|:----:|:----:|:----:|
|
||||
| 112 | 113 | 114 |
|
||||
|
||||
|
||||
## 国家税务总局
|
||||
|
||||
### 最新文件
|
||||
|
||||
@@ -16,6 +16,7 @@ module.exports = {
|
||||
'/miit/wjgs': ['Yoge-Code'],
|
||||
'/miit/zcjd': ['Yoge-Code'],
|
||||
'/mee/ywdt?': ['liuxsdev'],
|
||||
'/nrta/news/:category?': ['yuxinliu-alex'],
|
||||
'/pbc/goutongjiaoliu': ['nczitzk'],
|
||||
'/pbc/tradeAnnouncement': ['nczitzk'],
|
||||
'/pbc/zcyj': ['Fatpandac'],
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
const categories = {
|
||||
112: '总局要闻',
|
||||
113: '公告公示',
|
||||
114: '工作动态',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 112;
|
||||
|
||||
const rootUrl = 'http://www.nrta.gov.cn';
|
||||
|
||||
const currentUrl = `${rootUrl}/col/col${category}/index.html`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const regex = /<!\[CDATA\[([\s\S]*?)\]\]>(?=\s*<)/gi;
|
||||
const data = response.data.replace(regex, '$1');
|
||||
|
||||
const $ = cheerio.load(data, {
|
||||
normalizeWhitespace: true,
|
||||
xmlMode: true,
|
||||
});
|
||||
|
||||
const list = $('a', 'record')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
link: item.attr('href'),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
item.title = content('td[id="artTitMob"]').text();
|
||||
item.description = content('div[id="c"]').html();
|
||||
item.pubDate = timezone(parseDate(content('.mobile_time.shareWarpTime').text().trim()), +8);
|
||||
item.author = content('.mobile_time.shareFromz').text();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: category in categories ? categories[category] : '其他',
|
||||
link: `http://www.nrta.gov.cn/col/col${category}/index.html`,
|
||||
description: '国家广播电视总局',
|
||||
language: 'zh-cn',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -374,6 +374,17 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
},
|
||||
'nrta.gov.cn': {
|
||||
_name: '国家广播电视总局',
|
||||
'.': [
|
||||
{
|
||||
title: '分类',
|
||||
docs: 'https://docs.rsshub.app/government.html#nrta-gov',
|
||||
source: ['/col/*category'],
|
||||
target: (params) => `/gov/nrta/news/${params.category.replace('col', '').replace('/index.html', '')}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
'pbc.gov.cn': {
|
||||
_name: '中国人民银行',
|
||||
'.': [
|
||||
|
||||
@@ -17,6 +17,7 @@ module.exports = function (router) {
|
||||
router.get('/miit/wjgs', require('./miit/wjgs'));
|
||||
router.get('/miit/zcjd', require('./miit/zcjd'));
|
||||
router.get('/mee/ywdt/:category?', require('./mee/ywdt'));
|
||||
router.get('/nrta/news/:category?', require('./nrta/news'));
|
||||
router.get('/pbc/goutongjiaoliu', require('./pbc/goutongjiaoliu'));
|
||||
router.get('/pbc/tradeAnnouncement', require('./pbc/tradeAnnouncement'));
|
||||
router.get('/pbc/gzlw', require('./pbc/gzlw'));
|
||||
|
||||
Reference in New Issue
Block a user