mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-19 09:52:21 +08:00
feat: add type: 国家公派项目、国际合作与交流项目(in 研究生院)&& add route: 国家留学网 (#4157)
This commit is contained in:
@@ -1372,6 +1372,18 @@
|
||||
source: '/*',
|
||||
target: '/heu/yjsy/news',
|
||||
},
|
||||
{
|
||||
title: '研究生院 - 国家公派项目',
|
||||
docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue',
|
||||
source: '/*',
|
||||
target: '/heu/yjsy/gjgp',
|
||||
},
|
||||
{
|
||||
title: '研究生院 - 国际合作与交流项目',
|
||||
docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue',
|
||||
source: '/*',
|
||||
target: '/heu/yjsy/gjhz',
|
||||
},
|
||||
],
|
||||
uae: [
|
||||
{
|
||||
@@ -1447,4 +1459,33 @@
|
||||
},
|
||||
],
|
||||
},
|
||||
'csc.edu.cn': {
|
||||
_name: '国家留学网',
|
||||
www: [
|
||||
{
|
||||
title: '遴选通知',
|
||||
docs: 'https://docs.rsshub.app/other.html#guo-jia-liu-xue-wang',
|
||||
source: '/*',
|
||||
target: '/csc/notice/lxtz',
|
||||
},
|
||||
{
|
||||
title: '综合项目专栏',
|
||||
docs: 'https://docs.rsshub.app/other.html#guo-jia-liu-xue-wang',
|
||||
source: '/*',
|
||||
target: '/csc/notice/xmzl',
|
||||
},
|
||||
{
|
||||
title: '常见问题解答',
|
||||
docs: 'https://docs.rsshub.app/other.html#guo-jia-liu-xue-wang',
|
||||
source: '/*',
|
||||
target: '/csc/notice/wtjd',
|
||||
},
|
||||
{
|
||||
title: '录取公告',
|
||||
docs: 'https://docs.rsshub.app/other.html#guo-jia-liu-xue-wang',
|
||||
source: '/*',
|
||||
target: '/csc/notice/lqgg',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -236,6 +236,18 @@ type 为 all 时,category 参数不支持 cost 和 free
|
||||
|
||||
<Route author="LogicJake" example="/gushiwen/recommend" path="/gushiwen/recommend"/>
|
||||
|
||||
## 国家留学网
|
||||
|
||||
### 通知
|
||||
|
||||
<Route author="Derekmini" example="/csc/notice/lxtz" path="/csc/notice/:type?" :paramsDesc="['分类, 默认为 `lxtz`']" radar="1">
|
||||
|
||||
| 遴选通知 | 综合项目专栏 | 常见问题解答 | 录取公告 |
|
||||
| -------- | ------------ | ------------ | -------- |
|
||||
| lxtz | xmzl | wtjd | lqgg |
|
||||
|
||||
</Route>
|
||||
|
||||
## 国家自然科学基金委员会
|
||||
|
||||
### 新闻通知
|
||||
|
||||
+4
-4
@@ -387,11 +387,11 @@ category 列表:
|
||||
|
||||
### 研究生院
|
||||
|
||||
<Route author="XYenon" example="/heu/yjsy/announcement" path="/heu/yjsy/:type?" :paramsDesc="['分类, 默认为 `announcement`']" radar="1">
|
||||
<Route author="XYenon Derekmini" example="/heu/yjsy/announcement" path="/heu/yjsy/:type?" :paramsDesc="['分类, 默认为 `announcement`']" radar="1">
|
||||
|
||||
| 通知公告 | 新闻动态 |
|
||||
| ------------ | -------- |
|
||||
| announcement | news |
|
||||
| 通知公告 | 新闻动态 | 国家公派项目 | 国际合作与交流项目 |
|
||||
| ------------ | -------- | ------------ | ------------------ |
|
||||
| announcement | news | gjgp | gjhz |
|
||||
|
||||
</Route>
|
||||
|
||||
|
||||
@@ -2333,4 +2333,7 @@ router.get('/yzu/yjszs/:type', require('./routes/universities/yzu/yjszs'));
|
||||
// 国家自然科学基金委员会
|
||||
router.get('/nsfc/news/:type?', require('./routes/nsfc/news'));
|
||||
|
||||
// 国家留学网
|
||||
router.get('/csc/notice/:type?', require('./routes/csc/notice'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
const baseUrl = 'https://www.csc.edu.cn';
|
||||
|
||||
const typeMap = {
|
||||
lxtz: {
|
||||
name: '遴选通知',
|
||||
url: '/chuguo/list/24',
|
||||
},
|
||||
xmzl: {
|
||||
name: '综合项目专栏',
|
||||
url: '/chuguo/list/26',
|
||||
},
|
||||
wtjd: {
|
||||
name: '常见问题解答',
|
||||
url: '/chuguo/list/27',
|
||||
},
|
||||
lqgg: {
|
||||
name: '录取公告',
|
||||
url: '/chuguo/list/28',
|
||||
},
|
||||
};
|
||||
|
||||
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,
|
||||
},
|
||||
responseType: 'buffer',
|
||||
});
|
||||
const responseHtml = iconv.decode(response.data, 'gbk');
|
||||
const $ = cheerio.load(responseHtml);
|
||||
|
||||
const urlList = $('.list-a li')
|
||||
.slice(0, 10)
|
||||
.map((i, e) => $('a', e).attr('href'))
|
||||
.get();
|
||||
|
||||
const titleList = $('.list-a li')
|
||||
.slice(0, 10)
|
||||
.map((i, e) => $('a', e).attr('title'))
|
||||
.get();
|
||||
|
||||
const dateList = $('.list-a li')
|
||||
.slice(0, 10)
|
||||
.map((i, e) => $('span', e).text())
|
||||
.get();
|
||||
|
||||
const out = await Promise.all(
|
||||
urlList.map(async (itemUrl, index) => {
|
||||
itemUrl = url.resolve(baseUrl, itemUrl);
|
||||
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: itemUrl,
|
||||
responseType: 'buffer',
|
||||
});
|
||||
const responseHtmlItem = iconv.decode(response.data, 'gbk');
|
||||
const $ = cheerio.load(responseHtmlItem);
|
||||
const single = {
|
||||
title: titleList[index],
|
||||
link: itemUrl,
|
||||
description: $('.contents')
|
||||
.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);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '国家留学网-' + typeMap[type].name,
|
||||
link: link,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
@@ -2,7 +2,7 @@ const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
|
||||
const baseUrl = 'http://www.nsfc.gov.cn/';
|
||||
const baseUrl = 'http://www.nsfc.gov.cn';
|
||||
|
||||
const typeMap = {
|
||||
jjyw: {
|
||||
|
||||
@@ -13,6 +13,14 @@ const typeMap = {
|
||||
name: '新闻动态',
|
||||
url: '/2980/list.htm',
|
||||
},
|
||||
gjgp: {
|
||||
name: '国家公派项目',
|
||||
url: '/3015/list.htm',
|
||||
},
|
||||
gjhz: {
|
||||
name: '国际合作与交流项目',
|
||||
url: '/3016/list.htm',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
@@ -77,7 +85,7 @@ module.exports = async (ctx) => {
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '哈尔滨工程大学研究生院' + typeMap[type].name,
|
||||
title: '研究生院-' + typeMap[type].name,
|
||||
link: link,
|
||||
item: out,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user