feat(route): add 全国哲学社会科学工作办公室 (#10704)

* feat(route): add 全国哲学社会科学工作办公室

* add radar
This commit is contained in:
Ethan Shen 2022-09-05 22:39:23 +08:00 committed by GitHub
parent 0a92a54ca6
commit ea32d46ba9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 86 additions and 0 deletions

View File

@ -408,6 +408,22 @@ pageClass: routes
<Route author="nczitzk" example="/cia/foia-annual-report" path="/cia/foia-annual-report"/>
## 全国哲学社会科学工作办公室
### 通用
<Route author="nczitzk" example="/gov/nopss/GB/219469" path="/gov/nopss/:path+" :paramsDesc="['路径,默认为通知公告']">
::: tip 提示
路径处填写对应页面 URL 中 `http://www.nopss.gov.cn/` 后的字段。下面是一个例子。
若订阅 [年度项目、青年项目和西部项目](http://www.nopss.gov.cn/GB/219469/431027) 则将对应页面 URL <http://www.nopss.gov.cn/GB/219469/431027>`http://www.nopss.gov.cn/` 后的字段 `GB/219469/431027` 作为路径填入。此时路由为 [`/gov/nopss/GB/219469/431027`](https://rsshub.app/gov/nopss/GB/219469/431027)
:::
</Route>
## 泉州市跨境电子商务协会
### 新闻动态

View File

@ -26,6 +26,7 @@ module.exports = {
'/moj/aac/news/:type?': ['TonyRL'],
'/nifdc/:path+': ['nczitzk'],
'/nmpa/:path+': ['TonyRL'],
'/nopss/:path+': ['nczitzk'],
'/nrta/news/:category?': ['yuxinliu-alex'],
'/nsfc/news/:type?': ['Derekmini', 'nczitzk'],
'/pbc/goutongjiaoliu': ['nczitzk'],

57
lib/v2/gov/nopss/index.js Normal file
View File

@ -0,0 +1,57 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const iconv = require('iconv-lite');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const params = ctx.path === '/nopss' ? '/GB/219469' : ctx.path.replace(/^\/nopss/, '');
const rootUrl = 'http://www.nopss.gov.cn';
const currentUrl = `${rootUrl}${params}`;
const response = await got({
method: 'get',
url: currentUrl,
responseType: 'buffer',
});
const $ = cheerio.load(iconv.decode(response.data, 'gbk'));
let items = $('.p2j_list_con .clearfix li a')
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 40)
.toArray()
.map((item) => {
item = $(item);
return {
title: item.text(),
link: `${rootUrl}${item.attr('href')}`,
pubDate: timezone(parseDate(item.next().text(), '[YYYY-MM-DD HH:mm]'), +8),
};
});
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
responseType: 'buffer',
});
const content = cheerio.load(iconv.decode(detailResponse.data, 'gbk'));
item.description = content('.text_con').html();
return item;
})
)
);
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};

View File

@ -570,6 +570,17 @@ module.exports = {
},
],
},
'nopss.gov.cn': {
_name: '全国哲学社会科学工作办公室',
'.': [
{
title: '通用',
docs: 'https://docs.rsshub.app/government.html#quan-guo-zhe-xue-she-hui-ke-xue-gong-zuo-ban-gong-shi',
source: ['/*path'],
target: (params) => `/gov/nopss/${params.path.replace('/index.html', '')}`,
},
],
},
'nrta.gov.cn': {
_name: '国家广播电视总局',
'.': [

View File

@ -18,6 +18,7 @@ module.exports = function (router) {
router.get('/moj/aac/news/:type?', require('./moj/aac/news'));
router.get(/nifdc\/([\w/-]+)?/, require('./nifdc'));
router.get(/\/nmpa\/([\w][\w/]+)?/, require('./nmpa/generic'));
router.get(/nopss(\/[\w/-]+)?/, require('./nopss'));
router.get('/nrta/news/:category?', require('./nrta/news'));
router.get('/nsfc/news/:type?', require('./nsfc'));
router.get('/pbc/goutongjiaoliu', require('./pbc/goutongjiaoliu'));