feat(route): add 国家广播电视总局电视剧政务平台 (#12804)

* feat(route): add 国家广播电视总局电视剧政务平台

* fix: set pool limit to 5
This commit is contained in:
Ethan Shen
2023-07-16 13:51:31 +09:00
committed by GitHub
parent b9c832125e
commit 79d848f656
5 changed files with 89 additions and 3 deletions
+15 -3
View File
@@ -266,11 +266,23 @@ pageClass: routes
### 分类
<Route author="yuxinliu-alex" example="/gov/nrta/news" path="/gov/nrta/news/:category?" :paramsDesc="['资讯类别, 可从地址中获取,默认为总局要闻']"/>
<Route author="yuxinliu-alex" example="/gov/nrta/news" path="/gov/nrta/news/:category?" :paramsDesc="['资讯类别,可从地址中获取,默认为总局要闻']"/>
| 总局要闻 | 公告公示 | 工作动态 | 其他 |
| :------: | :------: | :------: | :--: |
| 112 | 113 | 114 | |
| -------- | -------- | -------- | ---- |
| 112 | 113 | 114 | |
</Route>
### 电视剧政务平台
<Route author="nczitzk" example="/gov/nrta/dsj" path="/gov/nrta/dsj/:category?" :paramsDesc="['分类,见下表,默认为备案公示']">
| 备案公示 | 发行许可通告 | 重大题材立项 | 重大题材摄制 | 变更通报 |
| -------- | ------------ | ---------------- | --------------- | -------- |
| note | announce | importantLixiang | importantShezhi | changing |
</Route>
## 国家税务总局
+1
View File
@@ -36,6 +36,7 @@ module.exports = {
'/nmpa/:path+': ['TonyRL'],
'/nopss/:path+': ['nczitzk'],
'/nrta/news/:category?': ['yuxinliu-alex'],
'/nrta/dsj/:category?': ['nczitzk'],
'/nsfc/news/:type?': ['Derekmini', 'nczitzk'],
'/pbc/goutongjiaoliu': ['nczitzk'],
'/pbc/gzlw': ['Fatpandac'],
+59
View File
@@ -0,0 +1,59 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const asyncPool = require('tiny-async-pool');
module.exports = async (ctx) => {
const { category = 'note' } = ctx.params;
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 15;
const rootUrl = 'https://dsj.nrta.gov.cn';
const currentUrl = new URL(`tims/site/views/applications.shanty?appName=${category}`, rootUrl).href;
const { data: response } = await got(currentUrl);
const $ = cheerio.load(response);
const items = $('img[src="/site/styles/default/images/icon_arrow_r.gif"]')
.slice(0, limit)
.toArray()
.map((item) => {
item = $(item).next();
const pubDateMatches = item.text().match(/(\d+年\d+月)/);
return {
title: item.text(),
link: new URL(item.prop('href'), rootUrl).href,
pubDate: pubDateMatches ? parseDate(pubDateMatches[1], ['YYYY年MM月', 'YYYY年M月']) : undefined,
};
});
const results = [];
for await (const item of asyncPool(5, items, (item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = cheerio.load(detailResponse);
content('table').last().remove();
item.description = content('td.newstext').html() || content('table').last().parent().parent().html();
return item;
})
)) {
results.push(item);
}
ctx.state.data = {
item: results,
title: `${$('title').text()}-${$('div.headbottom_menu_selected').text()}`,
link: currentUrl,
description: $('td').last().text(),
language: 'zh-cn',
image: $('img').first().prop('src'),
author: '国家广播电影电视总局电视剧管理司',
};
};
+13
View File
@@ -828,6 +828,19 @@ module.exports = {
target: (params) => `/gov/nrta/news/${params.category.replace('col', '').replace('/index.html', '')}`,
},
],
dsj: [
{
title: '电视剧政务平台',
docs: 'https://docs.rsshub.app/government.html#guo-jia-guang-bo-dian-shi-zong-ju',
source: ['/tims/site/views/applications.shanty', '/'],
target: (params, url) => {
url = new URL(url);
const category = url.searchParams.get('appName');
return `/gov/nrta/dsj/${category}`;
},
},
],
},
'nsfc.gov.cn': {
_name: '国家自然科学基金委员会',
+1
View File
@@ -28,6 +28,7 @@ module.exports = function (router) {
router.get(/\/nmpa\/([\w][\w/]+)?/, require('./nmpa/generic'));
router.get(/nopss(\/[\w/-]+)?/, require('./nopss'));
router.get('/nrta/news/:category?', require('./nrta/news'));
router.get('/nrta/dsj/:category?', require('./nrta/dsj'));
router.get('/nsfc/news/:type?', require('./nsfc'));
router.get('/pbc/goutongjiaoliu', require('./pbc/goutongjiaoliu'));
router.get('/pbc/gzlw', require('./pbc/gzlw'));