mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-19 09:52:21 +08:00
feat: add 西安交通大学研究生院通知公告 (#4748)
This commit is contained in:
@@ -1369,6 +1369,10 @@ type 列表:
|
||||
|
||||
<Route author="hoilc" example="/xjtu/dean/jxxx/xytz/ksap" path="/xjtu/dean/:subpath+" :paramsDesc="['栏目路径, 支持多级, 不包括末尾的`.htm`']">
|
||||
|
||||
### 研究生院通知公告
|
||||
|
||||
<Route author="nczitzk" example="/xjtu/gs/tzgg" path="/xjtu/gs/tzgg"/>
|
||||
|
||||
::: tip 提示
|
||||
|
||||
支持`http://dean.xjtu.edu.cn/`下所有**有文章列表**的栏目,
|
||||
|
||||
@@ -2406,6 +2406,7 @@ router.get('/wolley/user/:id', require('./routes/wolley/user'));
|
||||
router.get('/wolley/host/:host', require('./routes/wolley/host'));
|
||||
|
||||
// 西安交大
|
||||
router.get('/xjtu/gs/tzgg', require('./routes/universities/xjtu/gs/tzgg'));
|
||||
router.get('/xjtu/dean/:subpath+', require('./routes/universities/xjtu/dean'));
|
||||
|
||||
// booksource
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
const url = require('url');
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'http://gs.xjtu.edu.cn/tzgg.htm';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: rootUrl,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('div.list_right_con ul li')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a');
|
||||
return {
|
||||
title: a.text(),
|
||||
link: url.resolve('http://gs.xjtu.edu.cn/', a.attr('href')),
|
||||
pubDate: new Date(item.find('span.time').text()).toUTCString(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: '西安交通大学研究生院 - 通知公告',
|
||||
link: rootUrl,
|
||||
item: await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const res = await got({ method: 'get', url: item.link });
|
||||
const content = cheerio.load(res.data);
|
||||
item.description = content('#vsb_content').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user