mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-13 16:49:31 +08:00
feat(route): 中国留学网通知公告 (#10009)
* feat(route): 中国留学网通知公告 * docs: move to study
This commit is contained in:
@@ -533,6 +533,12 @@ path="/ctfhub/upcoming/:limit?"
|
||||
|
||||
<Route author="xyqfer" example="/icourse163/newest" path="/icourse163/newest" />
|
||||
|
||||
## 中国留学网
|
||||
|
||||
### 通知公告
|
||||
|
||||
<Route author="nczitzk" example="/cscse/tzgg" path="/cscse/tzgg"/>
|
||||
|
||||
## 中国人事考试网
|
||||
|
||||
### 通知公告
|
||||
|
||||
3
lib/v2/cscse/maintainer.js
Normal file
3
lib/v2/cscse/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/tzgg': ['nczitzk'],
|
||||
};
|
||||
13
lib/v2/cscse/radar.js
Normal file
13
lib/v2/cscse/radar.js
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'cscse.edu.cn': {
|
||||
_name: '中国留学网',
|
||||
'.': [
|
||||
{
|
||||
title: '通知公告',
|
||||
docs: 'https://docs.rsshub.app/study.html#zhong-guo-liu-xue-wang-tong-zhi-gong-gao',
|
||||
source: ['/cscse/index/tzgg', '/'],
|
||||
target: '/cscse/tzgg',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
3
lib/v2/cscse/router.js
Normal file
3
lib/v2/cscse/router.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/tzgg', require('./tzgg'));
|
||||
};
|
||||
54
lib/v2/cscse/tzgg.js
Normal file
54
lib/v2/cscse/tzgg.js
Normal file
@@ -0,0 +1,54 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://www.cscse.edu.cn';
|
||||
const currentUrl = `${rootUrl}/cscse/index/tzgg/index.html`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
let items = $('.news_list li a')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
const link = item.attr('href');
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${/^http/.test(link) ? '' : rootUrl}${item.attr('href')}`,
|
||||
pubDate: parseDate(item.next().text()),
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('.zoom').html();
|
||||
item.author = content('meta[name="Author"]').attr('content');
|
||||
item.category = content('meta[name="Keywords"]').attr('content')?.split(',');
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '中国留学网 - 通知公告',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user