mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
add feed for tj.ustb.edu.cn (#1859)
This commit is contained in:
@@ -678,3 +678,13 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet
|
|||||||
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
|
||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
## 北京科技大学天津学院
|
||||||
|
|
||||||
|
<Route name="北京科技大学天津学院" author="henbf" example="/ustb/tj/news/all" path="/universities/ustb/tj/news/:type" :paramsDesc="['默认为 `all`']">
|
||||||
|
|
||||||
|
| 全部 | 学院新闻 | 学术活动 | 城市建设学院 | 信息工程学院 | 经济学院 | 管理学院 | 材料系 | 机械工程系 | 护理系 | 法律系 | 外语系 | 艺术系 |
|
||||||
|
| ---- | -------- | -------- | ------------ | ------------ | -------- | -------- | ------ | ---------- | ------ | ------ | ------ | ------ |
|
||||||
|
| all | xyxw | xshhd | csjsxy | xxgcxy | jjx | glxy | clx | jxgcx | hlx | flx | wyx | ysx |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|||||||
@@ -726,6 +726,9 @@ router.get('/buaa/news/:type', require('./routes/universities/buaa/news/index'))
|
|||||||
// 上海大学
|
// 上海大学
|
||||||
router.get('/shu/jwc/:type?', require('./routes/universities/shu/jwc'));
|
router.get('/shu/jwc/:type?', require('./routes/universities/shu/jwc'));
|
||||||
|
|
||||||
|
// 北京科技大学天津学院
|
||||||
|
router.get('/ustb/tj/news/:type?', require('./routes/universities/ustb/tj/news'));
|
||||||
|
|
||||||
// ifanr
|
// ifanr
|
||||||
router.get('/ifanr/:channel?', require('./routes/ifanr/index'));
|
router.get('/ifanr/:channel?', require('./routes/ifanr/index'));
|
||||||
|
|
||||||
|
|||||||
62
lib/routes/universities/ustb/tj/news.js
Normal file
62
lib/routes/universities/ustb/tj/news.js
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
const axios = require('../../../../utils/axios');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const dayjs = require('dayjs');
|
||||||
|
const _ = require('lodash');
|
||||||
|
|
||||||
|
const baseUrl = 'http://tj.ustb.edu.cn';
|
||||||
|
const maps = {
|
||||||
|
xyxw: '/Class/xyxw/index.htm',
|
||||||
|
xshhd: '/Class/xshhd/index.htm',
|
||||||
|
csjsxy: '/Class/csjsxy/index.htm',
|
||||||
|
xxgcxy: '/Class/xxgcxy/index.htm',
|
||||||
|
jjx: '/Class/jjx/index.htm',
|
||||||
|
glxy: '/Class/glxy/index.htm',
|
||||||
|
clx: '/Class/clx/index.htm',
|
||||||
|
jxgcx: '/Class/jxgcx/index.htm',
|
||||||
|
hlx: '/Class/hlx/index.htm',
|
||||||
|
flx: '/Class/flx/index.htm',
|
||||||
|
wyx: '/Class/wyx/index.htm',
|
||||||
|
ysx: '/Class/ysx/index.htm',
|
||||||
|
};
|
||||||
|
|
||||||
|
function getNews(data) {
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
return $('div[class="classnews"] ul li a')
|
||||||
|
.slice(0, 5)
|
||||||
|
.map((_, elem) => ({
|
||||||
|
link: baseUrl + elem.attribs.href,
|
||||||
|
title: elem.children[0].data,
|
||||||
|
pubDate: dayjs(elem.attribs.href.split('/')[3].split('.')[0]).toString(),
|
||||||
|
}))
|
||||||
|
.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
let type = ctx.params.type || 'all';
|
||||||
|
if (!_.includes(_.keys(maps), type)) {
|
||||||
|
type = 'all';
|
||||||
|
}
|
||||||
|
|
||||||
|
const responseData = {
|
||||||
|
title: '北京科技大学天津学院新闻动态',
|
||||||
|
link: baseUrl,
|
||||||
|
item: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (type === 'all') {
|
||||||
|
const all = await Promise.all(
|
||||||
|
Object.values(maps).map(async (link) => {
|
||||||
|
const response = await axios.get(baseUrl + link);
|
||||||
|
const news = getNews(response.data);
|
||||||
|
return Promise.resolve(news);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
responseData.item = _.orderBy(_.flatMapDepth(all), (res) => new Date(res.pubDate), ['desc']);
|
||||||
|
} else {
|
||||||
|
const response = await axios.get(baseUrl + maps[type]);
|
||||||
|
const news = getNews(response.data);
|
||||||
|
responseData.item = news;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.state.data = responseData;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user