feat(route): add 国务院国有资产监督管理委员会 (#12875)
This commit is contained in:
parent
5c14f8a591
commit
e629dc23dc
|
|
@ -433,13 +433,45 @@ pageClass: routes
|
|||
|
||||
## 国家自然科学基金委员会
|
||||
|
||||
### 基金要闻
|
||||
### 通用
|
||||
|
||||
<Route author="Derekmini nczitzk" example="/gov/nsfc/news/jjyw" path="/gov/nsfc/news/:type?" :paramsDesc="['分类,默认为基金要闻,即 `jjyw`']" radar="1" rssbud="1">
|
||||
<Route author="Derekmini nczitzk" example="/gov/nsfc" path="/gov/nsfc/path+" :paramsDesc="['路径,默认为基金要闻']" radar="1" rssbud="1">
|
||||
|
||||
| 基金要闻 | 通知公告 | 资助成果 | 科普快讯 |
|
||||
| -------- | -------- | -------- | -------- |
|
||||
| jjyw | tzgg | zzcg | kpkx |
|
||||
::: tip 提示
|
||||
|
||||
若订阅 [基金要闻 - 通知公告](https://www.nsfc.gov.cn/publish/portal0/tab442),网址为 <https://www.nsfc.gov.cn/publish/portal0/tab442>。截取 `https://www.nsfc.gov.cn` 到末尾的部分 `/publish/portal0/tab442` 作为参数,此时路由为 [`/gov/nsfc/publish/portal0/tab442`](https://rsshub.app/gov/nsfc/publish/portal0/tab442)。
|
||||
|
||||
当然,也可以填入路径在下表中对应的快捷方式。其中 [基金要闻 - 通知公告](https://www.nsfc.gov.cn/publish/portal0/tab442) 的快捷方式为 `tzgg`,此时路由为 [`/gov/nsfc/tzgg`](https://rsshub.app/gov/nsfc/tzgg)。
|
||||
|
||||
若订阅 [管理科学部 - 通知公告](https://www.nsfc.gov.cn/publish/portal0/tab1212),网址为 <https://www.nsfc.gov.cn/publish/portal0/tab1212>。截取 `https://www.nsfc.gov.cn` 到末尾的部分 `/publish/portal0/tab1212` 作为参数,此时路由为 [`/gov/nsfc/publish/portal0/tab1212`](https://rsshub.app/gov/nsfc/publish/portal0/tab1212)。
|
||||
|
||||
同理,也可以填入路径在下表中对应的快捷方式。其中 [管理科学部 - 通知公告](https://www.nsfc.gov.cn/publish/portal0/tab1212) 的快捷方式为 `glkxb-tzgg`,此时路由为 [`/gov/nsfc/glkxb-tzgg`](https://rsshub.app/gov/nsfc/glkxb-tzgg)。
|
||||
|
||||
:::
|
||||
|
||||
基金要闻
|
||||
|
||||
| 基金要闻 | 通知公告 | 部门动态 | 科普快讯 | 资助成果 |
|
||||
| -------- | -------- | -------- | -------- | -------- |
|
||||
| jjyw | tzgg | bmdt | kpkx | zzcg |
|
||||
|
||||
政策法规
|
||||
|
||||
| 国家自然科学基金条例 | 国家自然科学基金发展规划 | 国家自然科学基金规章制度 | 国家科学技术相关法律法规 |
|
||||
| -------------------- | ------------------------ | ------------------------ | ------------------------ |
|
||||
| zcfg-jjtl | zcfg-fzgh | zcfg-gzzd | zcfg-flfg |
|
||||
|
||||
管理科学部
|
||||
|
||||
| 工作动态 | 通知公告 | 资助成果 |
|
||||
| ---------- | ---------- | ---------- |
|
||||
| glkxb-gzdt | glkxb-tzgg | glkxb-zzcg |
|
||||
|
||||
国际合作局
|
||||
|
||||
| 项目指南 | 初审结果 | 批准通知 | 进程简表 | 信息公开 |
|
||||
| ---------- | ---------- | ---------- | ---------- | ---------- |
|
||||
| gjhzj-xmzn | gjhzj-csjg | gjhzj-pztz | gjhzj-jcjb | gjhzj-xxgk |
|
||||
|
||||
</Route>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,74 +1,68 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const types = {
|
||||
jjyw: {
|
||||
title: '基金要闻',
|
||||
url: '/publish/portal0/tab440/',
|
||||
},
|
||||
tzgg: {
|
||||
title: '通知公告',
|
||||
url: '/publish/portal0/tab442/',
|
||||
},
|
||||
zzcg: {
|
||||
title: '资助成果',
|
||||
url: '/publish/portal0/tab448/',
|
||||
},
|
||||
kpkx: {
|
||||
title: '科普快讯',
|
||||
url: '/publish/portal0/tab446/',
|
||||
},
|
||||
};
|
||||
const shortcuts = require('./shortcuts');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type ?? 'jjyw';
|
||||
let thePath = ctx.path.replace(/^\/nsfc/, '');
|
||||
|
||||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30;
|
||||
|
||||
const shortcutMatches = thePath.match(/(\/news)?\/([\w-]+)/);
|
||||
|
||||
if (shortcutMatches) {
|
||||
const shortcut = shortcutMatches[2];
|
||||
if (shortcuts.hasOwnProperty(shortcut)) {
|
||||
thePath = shortcuts[shortcut];
|
||||
}
|
||||
}
|
||||
|
||||
const rootUrl = 'https://www.nsfc.gov.cn';
|
||||
const currentUrl = `${rootUrl}${types[type].url}`;
|
||||
const currentUrl = new URL((/\/more$/.test(thePath) ? `${thePath}.htm` : thePath) || 'publish/portal0/tab442/', rootUrl).href;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
const { data: response } = await got(currentUrl, {
|
||||
https: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
let items = $('.fl a')
|
||||
let items = $('span.fl a, ul.dp_lia li a')
|
||||
.slice(0, limit)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
const link = item.attr('href');
|
||||
|
||||
return {
|
||||
title: item.attr('title'),
|
||||
link: `${/^http/.test(link) ? '' : rootUrl}${link}`,
|
||||
pubDate: parseDate(item.parent().next().text()),
|
||||
title: item.prop('title') ?? item.text(),
|
||||
link: new URL(item.prop('href'), rootUrl).href,
|
||||
guid: `nsfc-${item.prop('id')}`,
|
||||
pubDate: parseDate(item.next().text().replace(/\[|\]/g, '', ['YYYY-MM-DD', 'YY-MM-DD'])),
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
if (/nsfc\.gov\.cn/.test(item.link)) {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
https: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
});
|
||||
const { data: detailResponse } = await got(item.link, {
|
||||
https: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
const content = cheerio.load(detailResponse);
|
||||
|
||||
item.description = content('.content_xilan').html();
|
||||
item.pubDate = timezone(parseDate(content('meta[name="docdate"]').attr('content')), +8);
|
||||
}
|
||||
item.title = content('div.title_xilan').text();
|
||||
item.description = content('#zoom').html();
|
||||
item.author = content('meta[name="docauthor"]').prop('content');
|
||||
item.category = [content('meta[name="channel"]').prop('content'), content('meta[name="docsource"]').prop('content')];
|
||||
item.pubDate = parseDate(
|
||||
content('div.line_xilan')
|
||||
.text()
|
||||
.match(/日期 (\d{4}-\d{2}-\d{2})/)[1]
|
||||
);
|
||||
|
||||
return item;
|
||||
})
|
||||
|
|
@ -76,8 +70,16 @@ module.exports = async (ctx) => {
|
|||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `国家自然科学基金委员会 - ${$('title').text()}`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
title: `国家自然科学基金委员会 - ${$('#ess_essBREADCRUMB_lblBreadCrumb a.break')
|
||||
.toArray()
|
||||
.slice(1)
|
||||
.map((a) => $(a).text())
|
||||
.join(' - ')}`,
|
||||
link: currentUrl,
|
||||
description: $('meta[name="DESCRIPTION"]').prop('content'),
|
||||
language: 'zh-cn',
|
||||
subtitle: $('meta[name="KEYWORDS"]').prop('content'),
|
||||
author: $('meta[name="AUTHOR"]').prop('content'),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
module.exports = {
|
||||
// 基金要闻 - 基金要闻 https://www.nsfc.gov.cn/publish/portal0/tab440/
|
||||
jjyw: '/publish/portal0/tab440/',
|
||||
|
||||
// 基金要闻 - 通知公告 https://www.nsfc.gov.cn/publish/portal0/tab442/
|
||||
tzgg: '/publish/portal0/tab442/',
|
||||
|
||||
// 基金要闻 - 部门动态 https://www.nsfc.gov.cn/publish/portal0/tab445/
|
||||
bmdt: '/publish/portal0/tab445/',
|
||||
|
||||
// 基金要闻 - 科普快讯 https://www.nsfc.gov.cn/publish/portal0/tab446/
|
||||
kpkx: '/publish/portal0/tab446/',
|
||||
|
||||
// 基金要闻 - 资助成果 https://www.nsfc.gov.cn/publish/portal0/tab448/
|
||||
zzcg: '/publish/portal0/tab448/',
|
||||
|
||||
// 政策法规 - 国家自然科学基金条例 https://www.nsfc.gov.cn/publish/portal0/tab471/
|
||||
'zcfg-jjtl': '/publish/portal0/tab471/',
|
||||
|
||||
// 政策法规 - 国家自然科学基金发展规划 https://www.nsfc.gov.cn/publish/portal0/tab473/
|
||||
'zcfg-fzgh': '/publish/portal0/tab473/',
|
||||
|
||||
// 政策法规 - 国家自然科学基金规章制度 https://www.nsfc.gov.cn/publish/portal0/tab475/
|
||||
'zcfg-gzzd': '/publish/portal0/tab475/',
|
||||
|
||||
// 政策法规 - 国家科学技术相关法律法规 https://www.nsfc.gov.cn/publish/portal0/tab609/
|
||||
'zcfg-flfg': '/publish/portal0/tab609/',
|
||||
|
||||
// 管理科学部 - 工作动态 https://www.nsfc.gov.cn/publish/portal0/tab1210/
|
||||
'glkxb-gzdt': '/publish/portal0/tab1210/',
|
||||
|
||||
// 管理科学部 - 通知公告 https://www.nsfc.gov.cn/publish/portal0/tab1212/
|
||||
'glkxb-tzgg': '/publish/portal0/tab1212/',
|
||||
|
||||
// 管理科学部 - 资助成果 https://www.nsfc.gov.cn/publish/portal0/tab1213/
|
||||
'glkxb-zzcg': '/publish/portal0/tab1213/',
|
||||
|
||||
// 国际合作局 - 项目指南 https://www.nsfc.gov.cn/publish/portal0/tab1356/
|
||||
'gjhzj-xmzn': '/publish/portal0/tab1356/',
|
||||
|
||||
// 国际合作局 - 初审结果 https://www.nsfc.gov.cn/publish/portal0/tab1361/
|
||||
'gjhzj-csjg': '/publish/portal0/tab1361/',
|
||||
|
||||
// 国际合作局 - 批准通知 https://www.nsfc.gov.cn/publish/portal0/tab1362/
|
||||
'gjhzj-pztz': '/publish/portal0/tab1362/',
|
||||
|
||||
// 国际合作局 - 进程简表 https://www.nsfc.gov.cn/publish/portal0/tab1366/
|
||||
'gjhzj-jcjb': '/publish/portal0/tab1366/',
|
||||
|
||||
// 国际合作局 - 信息公开 https://www.nsfc.gov.cn/publish/portal0/tab1386/
|
||||
'gjhzj-xxgk': '/publish/portal0/tab1386/',
|
||||
};
|
||||
|
|
@ -29,7 +29,7 @@ module.exports = function (router) {
|
|||
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(/nsfc(\/[\w-/]+)?/, require('./nsfc'));
|
||||
router.get('/pbc/goutongjiaoliu', require('./pbc/goutongjiaoliu'));
|
||||
router.get('/pbc/gzlw', require('./pbc/gzlw'));
|
||||
router.get('/pbc/tradeAnnouncement', require('./pbc/tradeAnnouncement'));
|
||||
|
|
|
|||
Loading…
Reference in New Issue