feat(route): add 西安交通大学第二附属医院新闻 (#10075)
* feat(route): add 西安交通大学第二附属医院新闻 * fix: selector
This commit is contained in:
parent
88cce18124
commit
0815cc3b22
|
|
@ -2567,6 +2567,25 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
|
|||
|
||||
</Route>
|
||||
|
||||
### 第二附属医院新闻
|
||||
|
||||
<Route author="nczitzk" example="/xjtu/2yuan/news" path="/xjtu/2yuan/news/:id?" :paramsDesc="['编号,见下表,默认为通知公告']">
|
||||
|
||||
| 分类 | 编号 |
|
||||
| ---- | --- |
|
||||
| 通知公告 | 110 |
|
||||
| 综合新闻 | 6 |
|
||||
| 科室动态 | 8 |
|
||||
| 教学动态 | 45 |
|
||||
| 科研动态 | 51 |
|
||||
| 护理动态 | 57 |
|
||||
| 党群活动 | 63 |
|
||||
| 外事活动 | 13 |
|
||||
| 媒体二院 | 14 |
|
||||
| 理论政策 | 16 |
|
||||
|
||||
</Route>
|
||||
|
||||
## 西安理工大学
|
||||
|
||||
### 学校主页
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id ?? '110';
|
||||
|
||||
const rootUrl = 'http://2yuan.xjtu.edu.cn';
|
||||
const currentUrl = `${rootUrl}/Html/News/Columns/${id}/Index.html`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
let items = $('.column_list h2')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find('a').attr('title'),
|
||||
link: `${rootUrl}${item.find('a').attr('href')}`,
|
||||
pubDate: timezone(parseDate(item.find('.dy_date').text()), +8),
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('#zoom').html();
|
||||
item.pubDate = timezone(
|
||||
parseDate(
|
||||
content('.sub_tit3 strong')
|
||||
.first()
|
||||
.text()
|
||||
.replace(/发布时间:/, '')
|
||||
),
|
||||
+8
|
||||
);
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
module.exports = {
|
||||
'/2yuan/news/:id?': ['nczitzk'],
|
||||
'/dean/:subpath+': ['hoilc'],
|
||||
'/ee/:id?': ['DylanXie123'],
|
||||
'/gs/tzgg': ['nczitzk'],
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
module.exports = {
|
||||
'xjtu.edu.cn': {
|
||||
_name: '西安交通大学',
|
||||
'2yuan': [
|
||||
{
|
||||
title: '第二附属医院新闻',
|
||||
docs: 'https://docs.rsshub.app/university.html#xi-an-jiao-tong-da-xue-di-er-fu-shu-yi-yuan-xin-wen',
|
||||
source: ['/'],
|
||||
target: (params, url) => `/xjtu/2yuan/news/${new URL(url).toString().match(/\/Columns\/(\d+)\//)[1]}`,
|
||||
},
|
||||
],
|
||||
dean: [
|
||||
{
|
||||
title: '教务处',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/2yuan/news/:id?', require('./2yuan/news'));
|
||||
router.get('/dean/:subpath+', require('./dean'));
|
||||
router.get('/ee/:id?', require('./ee'));
|
||||
router.get('/gs/tzgg', require('./gs/tzgg'));
|
||||
|
|
|
|||
Loading…
Reference in New Issue