feat(route): add chsi rss (#11523)

* feat(route): add yzw rss

* fix: namespace

* fix: path
This commit is contained in:
SunBK201 2023-01-01 01:07:24 +08:00 committed by GitHub
parent 3ebe76eae2
commit fe560d28fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 76 additions and 0 deletions

View File

@ -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" />
## 中国智库网
### 观点与实践

51
lib/v2/chsi/kydt.js Normal file
View File

@ -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,
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/kydt': ['SunBK201'],
};

13
lib/v2/chsi/radar.js Normal file
View File

@ -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',
},
],
},
};

3
lib/v2/chsi/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/kydt', require('./kydt'));
};