mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-13 08:39:38 +08:00
feat(route): add support for XAUFE jiaowu route (#11740)
* feat(route): XAUFE jiaowu * feat(route): support radar for XAUFE route * fix: Incomplete string escaping or encoding * Apply suggestions from code review Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix: excessive slice --------- Co-authored-by: Tony <TonyRL@users.noreply.github.com>
This commit is contained in:
@@ -2983,6 +2983,18 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
|
|||||||
|
|
||||||
<Route author="dingyx99" example="/nwafu/cie" path="/nwafu/cie" />
|
<Route author="dingyx99" example="/nwafu/cie" path="/nwafu/cie" />
|
||||||
|
|
||||||
|
## 西安财经大学
|
||||||
|
|
||||||
|
### 教务处
|
||||||
|
|
||||||
|
<Route author="shaokeyibb" example="/xaufe/jiaowu/tzgg" path="/xaufe/jiaowu/:category?" :paramsDesc="['分类,默认为通知公告']" radar="1" rssbud="1">
|
||||||
|
|
||||||
|
| 通知公告 |
|
||||||
|
| :--: |
|
||||||
|
| tzgg |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
## 西南财经大学
|
## 西南财经大学
|
||||||
|
|
||||||
### 经济信息工程学院
|
### 经济信息工程学院
|
||||||
|
|||||||
72
lib/v2/xaufe/jiaowu.js
Normal file
72
lib/v2/xaufe/jiaowu.js
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
// Yep http is bad, but I had no choice :(
|
||||||
|
const rootMeta = {
|
||||||
|
url: 'http://jiaowu.xaufe.edu.cn/',
|
||||||
|
title: '西安财经大学 教务处(招生办公室)',
|
||||||
|
};
|
||||||
|
|
||||||
|
const categories = {
|
||||||
|
tzgg: {
|
||||||
|
title: '通知公告',
|
||||||
|
url: 'index/tzgg.htm',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const pCategory = ctx.params.category;
|
||||||
|
const category = categories[pCategory] || categories.tzgg;
|
||||||
|
|
||||||
|
const response = (
|
||||||
|
await got({
|
||||||
|
method: 'get',
|
||||||
|
url: rootMeta.url + category.url,
|
||||||
|
})
|
||||||
|
).body;
|
||||||
|
|
||||||
|
const $ = cheerio.load(response);
|
||||||
|
|
||||||
|
const data = $('.main_conRCb ul li')
|
||||||
|
.slice(0, 16)
|
||||||
|
.toArray()
|
||||||
|
.map((item) => {
|
||||||
|
item = $(item);
|
||||||
|
const pubDate = item.children('span').text();
|
||||||
|
const title = item.find('a em').text();
|
||||||
|
const link = item
|
||||||
|
.children('a')
|
||||||
|
.attr('href')
|
||||||
|
.replace(/\.\.\//g, rootMeta.url);
|
||||||
|
return {
|
||||||
|
pubDate: parseDate(pubDate),
|
||||||
|
title,
|
||||||
|
link,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `${category.title}-${rootMeta.title}`,
|
||||||
|
link: rootMeta.url + category.url,
|
||||||
|
description: `${category.title}-${rootMeta.title}`,
|
||||||
|
language: 'zh_CN',
|
||||||
|
item: await Promise.all(
|
||||||
|
data.map((item) =>
|
||||||
|
ctx.cache.tryGet(item.link, async () => {
|
||||||
|
const $ = cheerio.load(
|
||||||
|
(
|
||||||
|
await got({
|
||||||
|
method: 'get',
|
||||||
|
url: item.link,
|
||||||
|
})
|
||||||
|
).body
|
||||||
|
);
|
||||||
|
item.author = /作者:(\S*)\s{4}/g.exec($('p', '.main_contit').text())[1];
|
||||||
|
item.description = $('#vsb_content').html();
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
),
|
||||||
|
};
|
||||||
|
};
|
||||||
3
lib/v2/xaufe/maintainer.js
Normal file
3
lib/v2/xaufe/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/jiaowu/:category?': ['shaokeyibb'],
|
||||||
|
};
|
||||||
11
lib/v2/xaufe/radar.js
Normal file
11
lib/v2/xaufe/radar.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
module.exports = {
|
||||||
|
'xaufe.edu.cn': {
|
||||||
|
_name: '西安财经大学',
|
||||||
|
jiaowu: [
|
||||||
|
{
|
||||||
|
title: '教务处',
|
||||||
|
docs: 'https://docs.rsshub.app/university.html#xi-an-cai-jing-da-xue',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
};
|
||||||
3
lib/v2/xaufe/router.js
Normal file
3
lib/v2/xaufe/router.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = function (router) {
|
||||||
|
router.get('/jiaowu/:category?', require('./jiaowu'));
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user