diff --git a/docs/government.md b/docs/government.md
index 10d241860..0eb9250a9 100644
--- a/docs/government.md
+++ b/docs/government.md
@@ -265,6 +265,18 @@ pageClass: routes
+## 国家自然科学基金委员会
+
+### 基金要闻
+
+
+
+| 基金要闻 | 通知公告 | 资助成果 | 科普快讯 |
+| ---- | ---- | ---- | ---- |
+| jjyw | tzgg | zzcg | kpkx |
+
+
+
## 哈尔滨市科技局
### 政务公开
diff --git a/docs/other.md b/docs/other.md
index 04ec75ef0..9eb8c156d 100644
--- a/docs/other.md
+++ b/docs/other.md
@@ -461,18 +461,6 @@ type 为 all 时,category 参数不支持 cost 和 free
-## 国家自然科学基金委员会
-
-### 新闻通知
-
-
-
-| 基金要闻 | 通知公告 | 资助成果 | 科普快讯 |
-| ---- | ---- | ---- | ---- |
-| jjyw | tzgg | zzcg | kpkx |
-
-
-
## 好队友
### 工作机会
diff --git a/lib/radar-rules.js b/lib/radar-rules.js
index fa9930cd9..8d4fe0df0 100644
--- a/lib/radar-rules.js
+++ b/lib/radar-rules.js
@@ -1089,35 +1089,35 @@ module.exports = {
},
],
},
- 'nsfc.gov.cn': {
- _name: '国家自然科学基金委员会',
- www: [
- {
- title: '基金要闻',
- docs: 'https://docs.rsshub.app/other.html#guo-jia-zi-ran-ke-xue-ji-jin-wei-yuan-hui',
- source: '/*',
- target: '/nsfc/news/jjyw',
- },
- {
- title: '通知公告',
- docs: 'https://docs.rsshub.app/other.html#guo-jia-zi-ran-ke-xue-ji-jin-wei-yuan-hui',
- source: '/*',
- target: '/nsfc/news/tzgg',
- },
- {
- title: '资助成果',
- docs: 'https://docs.rsshub.app/other.html#guo-jia-zi-ran-ke-xue-ji-jin-wei-yuan-hui',
- source: '/*',
- target: '/nsfc/news/zzcg',
- },
- {
- title: '科普快讯',
- docs: 'https://docs.rsshub.app/other.html#guo-jia-zi-ran-ke-xue-ji-jin-wei-yuan-hui',
- source: '/*',
- target: '/nsfc/news/kpkx',
- },
- ],
- },
+ // 'nsfc.gov.cn': {
+ // _name: '国家自然科学基金委员会',
+ // www: [
+ // {
+ // title: '基金要闻',
+ // docs: 'https://docs.rsshub.app/other.html#guo-jia-zi-ran-ke-xue-ji-jin-wei-yuan-hui',
+ // source: '/*',
+ // target: '/nsfc/news/jjyw',
+ // },
+ // {
+ // title: '通知公告',
+ // docs: 'https://docs.rsshub.app/other.html#guo-jia-zi-ran-ke-xue-ji-jin-wei-yuan-hui',
+ // source: '/*',
+ // target: '/nsfc/news/tzgg',
+ // },
+ // {
+ // title: '资助成果',
+ // docs: 'https://docs.rsshub.app/other.html#guo-jia-zi-ran-ke-xue-ji-jin-wei-yuan-hui',
+ // source: '/*',
+ // target: '/nsfc/news/zzcg',
+ // },
+ // {
+ // title: '科普快讯',
+ // docs: 'https://docs.rsshub.app/other.html#guo-jia-zi-ran-ke-xue-ji-jin-wei-yuan-hui',
+ // source: '/*',
+ // target: '/nsfc/news/kpkx',
+ // },
+ // ],
+ // },
'japanpost.jp': {
_name: '日本郵便',
'trackings.post': [
diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js
index a8deb6f6d..db66b7bf0 100644
--- a/lib/v2/gov/maintainer.js
+++ b/lib/v2/gov/maintainer.js
@@ -13,6 +13,7 @@ module.exports = {
'/moe/:type': ['Crawler995'],
'/nmpa/:path+': ['TonyRL'],
'/nrta/news/:category?': ['yuxinliu-alex'],
+ '/nsfc/news/:type?': ['Derekmini', 'nczitzk'],
'/pbc/goutongjiaoliu': ['nczitzk'],
'/pbc/gzlw': ['Fatpandac'],
'/pbc/tradeAnnouncement': ['nczitzk'],
diff --git a/lib/v2/gov/nsfc/index.js b/lib/v2/gov/nsfc/index.js
new file mode 100644
index 000000000..3de3d209c
--- /dev/null
+++ b/lib/v2/gov/nsfc/index.js
@@ -0,0 +1,83 @@
+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/',
+ },
+};
+
+module.exports = async (ctx) => {
+ const type = ctx.params.type ?? 'jjyw';
+
+ const rootUrl = 'https://www.nsfc.gov.cn';
+ const currentUrl = `${rootUrl}${types[type].url}`;
+
+ const response = await got({
+ method: 'get',
+ url: currentUrl,
+ https: {
+ rejectUnauthorized: false,
+ },
+ });
+
+ const $ = cheerio.load(response.data);
+
+ let items = $('.fl a')
+ .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()),
+ };
+ });
+
+ 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 content = cheerio.load(detailResponse.data);
+
+ item.description = content('.content_xilan').html();
+ item.pubDate = timezone(parseDate(content('meta[name="docdate"]').attr('content')), +8);
+ }
+
+ return item;
+ })
+ )
+ );
+
+ ctx.state.data = {
+ title: `国家自然科学基金委员会 - ${$('title').text()}`,
+ link: currentUrl,
+ item: items,
+ };
+};
diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js
index 62d35169e..7973faec4 100644
--- a/lib/v2/gov/radar.js
+++ b/lib/v2/gov/radar.js
@@ -450,6 +450,17 @@ module.exports = {
},
],
},
+ 'nmpa.gov.cn': {
+ _name: '国家药品监督管理局',
+ '.': [
+ {
+ title: '通用',
+ docs: 'https://docs.rsshub.app/government.html#guo-jia-yao-pin-jian-du-guan-li-ju',
+ source: ['/*path'],
+ target: (params) => `/gov/nmpa/${params.path.replace('/index.html', '')}`,
+ },
+ ],
+ },
'nrta.gov.cn': {
_name: '国家广播电视总局',
'.': [
@@ -461,14 +472,32 @@ module.exports = {
},
],
},
- 'nmpa.gov.cn': {
- _name: '国家药品监督管理局',
+ 'nsfc.gov.cn': {
+ _name: '国家自然科学基金委员会',
'.': [
{
- title: '通用',
- docs: 'https://docs.rsshub.app/government.html#guo-jia-yao-pin-jian-du-guan-li-ju',
- source: ['/*path'],
- target: (params) => `/gov/nmpa/${params.path.replace('/index.html', '')}`,
+ title: '基金要闻',
+ docs: 'https://docs.rsshub.app/other.html#guo-jia-zi-ran-ke-xue-ji-jin-wei-yuan-hui-ji-jin-yao-wen',
+ source: ['/*'],
+ target: '/nsfc/news/jjyw',
+ },
+ {
+ title: '通知公告',
+ docs: 'https://docs.rsshub.app/other.html#guo-jia-zi-ran-ke-xue-ji-jin-wei-yuan-hui-ji-jin-yao-wen',
+ source: ['/*'],
+ target: '/nsfc/news/tzgg',
+ },
+ {
+ title: '资助成果',
+ docs: 'https://docs.rsshub.app/other.html#guo-jia-zi-ran-ke-xue-ji-jin-wei-yuan-hui-ji-jin-yao-wen',
+ source: ['/*'],
+ target: '/nsfc/news/zzcg',
+ },
+ {
+ title: '科普快讯',
+ docs: 'https://docs.rsshub.app/other.html#guo-jia-zi-ran-ke-xue-ji-jin-wei-yuan-hui-ji-jin-yao-wen',
+ source: ['/*'],
+ target: '/nsfc/news/kpkx',
},
],
},
diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js
index 3163b64a4..094b7fa03 100644
--- a/lib/v2/gov/router.js
+++ b/lib/v2/gov/router.js
@@ -13,6 +13,7 @@ module.exports = function (router) {
router.get('/moe/:type', require('./moe/moe'));
router.get(/\/nmpa\/([\w][\w/]+)?/, require('./nmpa/generic'));
router.get('/nrta/news/:category?', require('./nrta/news'));
+ router.get('/nsfc/news/:type?', require('./nsfc'));
router.get('/pbc/goutongjiaoliu', require('./pbc/goutongjiaoliu'));
router.get('/pbc/gzlw', require('./pbc/gzlw'));
router.get('/pbc/tradeAnnouncement', require('./pbc/tradeAnnouncement'));
diff --git a/lib/v2/nsfc/maintainer.js b/lib/v2/nsfc/maintainer.js
deleted file mode 100644
index a5098aa71..000000000
--- a/lib/v2/nsfc/maintainer.js
+++ /dev/null
@@ -1,3 +0,0 @@
-module.exports = {
- '/news/:type?': ['Derekmini'],
-};
diff --git a/lib/v2/nsfc/news.js b/lib/v2/nsfc/news.js
deleted file mode 100644
index cd784e142..000000000
--- a/lib/v2/nsfc/news.js
+++ /dev/null
@@ -1,92 +0,0 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-const url = require('url');
-
-const baseUrl = 'http://www.nsfc.gov.cn';
-
-const typeMap = {
- jjyw: {
- name: '基金要闻',
- url: '/publish/portal0/tab440/',
- },
- tzgg: {
- name: '通知公告',
- url: '/publish/portal0/tab442/',
- },
- zzcg: {
- name: '资助成果',
- url: '/publish/portal0/tab448/',
- },
- kpkx: {
- name: '科普快讯',
- url: '/publish/portal0/tab446/',
- },
-};
-
-module.exports = async (ctx) => {
- const type = ctx.params.type || 'jjyw';
- const link = baseUrl + typeMap[type].url;
- const response = await got({
- method: 'get',
- url: link,
- headers: {
- Referer: baseUrl,
- },
- });
- const $ = cheerio.load(response.data);
-
- const urlList = $('.contentnews .clearfix')
- .slice(0, 10)
- .map((i, e) => $('a', e).attr('href'))
- .get();
-
- const titleList = $('.contentnews .clearfix')
- .slice(0, 10)
- .map((i, e) => $('a', e).attr('title'))
- .get();
-
- const dateList = $('.contentnews .clearfix')
- .slice(0, 10)
- .map((i, e) => $('.fr', e).text())
- .get();
-
- const out = await Promise.all(
- urlList.map(async (itemUrl, index) => {
- itemUrl = url.resolve(baseUrl, itemUrl);
- if (itemUrl.indexOf('.htm') !== -1) {
- const cache = await ctx.cache.get(itemUrl);
- if (cache) {
- return Promise.resolve(JSON.parse(cache));
- }
- const response = await got.get(itemUrl);
- const $ = cheerio.load(response.data);
- const single = {
- title: titleList[index],
- link: itemUrl,
- description: $('.content_xilan')
- .html()
- .replace(/src="\//g, `src="${url.resolve(baseUrl, '.')}`)
- .replace(/href="\//g, `href="${url.resolve(baseUrl, '.')}`)
- .trim(),
- pubDate: dateList[index],
- };
- ctx.cache.set(itemUrl, JSON.stringify(single));
- return Promise.resolve(single);
- } else {
- const single = {
- title: titleList[index],
- link: itemUrl,
- description: '此链接为文件,请点击下载',
- pubDate: dateList[index],
- };
- return Promise.resolve(single);
- }
- })
- );
-
- ctx.state.data = {
- title: '国家自然科学基金委员会-' + typeMap[type].name,
- link,
- item: out,
- };
-};
diff --git a/lib/v2/nsfc/radar.js b/lib/v2/nsfc/radar.js
deleted file mode 100644
index 2b802eaca..000000000
--- a/lib/v2/nsfc/radar.js
+++ /dev/null
@@ -1,31 +0,0 @@
-module.exports = {
- 'nsfc.gov.cn': {
- _name: '国自然基金委',
- www: [
- {
- title: '基金要闻',
- docs: 'https://docs.rsshub.app/other.html#guo-jia-zi-ran-ke-xue-ji-jin-wei-yuan-hui',
- source: '/*',
- target: '/nsfc/news/jjyw',
- },
- {
- title: '通知公告',
- docs: 'https://docs.rsshub.app/other.html#guo-jia-zi-ran-ke-xue-ji-jin-wei-yuan-hui',
- source: '/*',
- target: '/nsfc/news/tzgg',
- },
- {
- title: '资助成果',
- docs: 'https://docs.rsshub.app/other.html#guo-jia-zi-ran-ke-xue-ji-jin-wei-yuan-hui',
- source: '/*',
- target: '/nsfc/news/zzcg',
- },
- {
- title: '科普快讯',
- docs: 'https://docs.rsshub.app/other.html#guo-jia-zi-ran-ke-xue-ji-jin-wei-yuan-hui',
- source: '/*',
- target: '/nsfc/news/kpkx',
- },
- ],
- },
-};
diff --git a/lib/v2/nsfc/router.js b/lib/v2/nsfc/router.js
deleted file mode 100644
index c36fd4f1c..000000000
--- a/lib/v2/nsfc/router.js
+++ /dev/null
@@ -1,3 +0,0 @@
-module.exports = function (router) {
- router.get('/news/:type?', require('./news'));
-};