fix(route): 太原师范路由修复 (#10410)
* fix router tynu. * refactor: migrate to v2
This commit is contained in:
+3
-1
@@ -2461,7 +2461,9 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
|
||||
|
||||
## 太原师范学院
|
||||
|
||||
<Route author="2PoL" example="/tynu" path="/tynu" />
|
||||
### 通知公告
|
||||
|
||||
<Route author="2PoL" example="/tynu" path="/tynu" rssbud="1" radar="1"/>
|
||||
|
||||
## 天津大学
|
||||
|
||||
|
||||
+1
-1
@@ -762,7 +762,7 @@ router.get('/upc/jsj/:type?', lazyloadRouteHandler('./routes/universities/upc/js
|
||||
// router.get('/ncwu/notice', lazyloadRouteHandler('./routes/universities/ncwu/notice'));
|
||||
|
||||
// 太原师范学院
|
||||
router.get('/tynu', lazyloadRouteHandler('./routes/universities/tynu/tynu'));
|
||||
// router.get('/tynu', lazyloadRouteHandler('./routes/universities/tynu/tynu'));
|
||||
|
||||
// 中北大学
|
||||
router.get('/nuc/:type', lazyloadRouteHandler('./routes/universities/nuc/index'));
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = 'http://www.tynu.edu.cn/index/xyxw.htm';
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.winstyle197529 a[class="c197529"]');
|
||||
|
||||
ctx.state.data = {
|
||||
title: '太原师范学院校园新闻',
|
||||
link,
|
||||
item:
|
||||
list &&
|
||||
list
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.text(),
|
||||
description: item.text(),
|
||||
link: item.attr('href'),
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/': ['2PoL'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'tynu.edu.cn': {
|
||||
_name: '太原师范学院',
|
||||
'.': [
|
||||
{
|
||||
title: '通知公告',
|
||||
docs: 'https://docs.rsshub.app/university.html#tai-yuan-shi-fan-xue-yuan',
|
||||
source: ['/index/tzgg.htm', '/index.htm', '/'],
|
||||
target: '/tynu',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/', require('./tynu'));
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const baseUrl = 'http://www.tynu.edu.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = `${baseUrl}/index/tzgg.htm`;
|
||||
const response = await got(link);
|
||||
const data = response.data;
|
||||
|
||||
const $ = cheerio.load(data);
|
||||
const list = $('.news_content_list')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find('h3').text(),
|
||||
link: new URL(item.find($('a')).attr('href'), baseUrl).href,
|
||||
pubDate: parseDate(item.find('.content_list_time').text(), 'YYYYMM-DD'),
|
||||
};
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const response = await got(item.link);
|
||||
const $ = cheerio.load(response.data);
|
||||
item.description = $('#vsb_content').html() + ($('.content ul').not('.btm-cate').html() || '');
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '太原师范学院通知公告',
|
||||
link,
|
||||
item: list,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user