feat(route): add chsi rss (#11523)
* feat(route): add yzw rss * fix: namespace * fix: path
This commit is contained in:
parent
3ebe76eae2
commit
fe560d28fb
|
|
@ -651,6 +651,12 @@ path="/ctfhub/upcoming/:limit?"
|
|||
|
||||
<Route author="nczitzk" example="/cpta/notice" path="/cpta/notice" />
|
||||
|
||||
## 中国研究生招生信息网
|
||||
|
||||
### 考研动态
|
||||
|
||||
<Route author="SunBK201" example="/chsi/kydt" path="/chsi/kydt" radar="1" />
|
||||
|
||||
## 中国智库网
|
||||
|
||||
### 观点与实践
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const host = 'https://yz.chsi.com.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got(`${host}/kyzx/kydt`);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('ul.news-list').children();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((i, item) => {
|
||||
item = $(item);
|
||||
const itemTitle = item.find('a').text();
|
||||
const itemDate = item.find('.span-time').text();
|
||||
const path = item.find('a').attr('href');
|
||||
let itemUrl = '';
|
||||
if (!path.startsWith('https://') && !path.startsWith('http://')) {
|
||||
itemUrl = host + path;
|
||||
} else {
|
||||
itemUrl = path;
|
||||
}
|
||||
return ctx.cache.tryGet(itemUrl, async () => {
|
||||
let description = '';
|
||||
if (!path.startsWith('https://') && !path.startsWith('http://')) {
|
||||
const result = await got(itemUrl);
|
||||
const $ = cheerio.load(result.data);
|
||||
description = $('#article_dnull').html().trim();
|
||||
} else {
|
||||
description = itemTitle;
|
||||
}
|
||||
return {
|
||||
title: itemTitle,
|
||||
link: itemUrl,
|
||||
pubDate: timezone(parseDate(itemDate), 8),
|
||||
description,
|
||||
};
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `中国研究生招生信息网 - 考研动态`,
|
||||
link: `${host}/kyzx/kydt/`,
|
||||
description: '中国研究生招生信息网 - 考研动态',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/kydt': ['SunBK201'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'chsi.com.cn': {
|
||||
_name: '中国研究生招生信息网',
|
||||
yz: [
|
||||
{
|
||||
title: '考研动态',
|
||||
docs: 'https://docs.rsshub.app/study.html#zhong-guo-yan-jiu-sheng-zhao-sheng-xin-xi-wang',
|
||||
source: ['/kyzx/kydt'],
|
||||
target: '/chsi/kydt',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/kydt', require('./kydt'));
|
||||
};
|
||||
Loading…
Reference in New Issue