feat(route): Add qdu houqin (#14515)
* feat(route): Add qdu houqin * feat(route): qdu houqin - more accurate time * fix: alphabetical order * fix: unnecessary condition ---------
This commit is contained in:
parent
88a594eea6
commit
0d47d01994
|
|
@ -0,0 +1,63 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const base = 'https://houqin.qdu.edu.cn/';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `${base}index/tzgg.htm`,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('.n_newslist').children();
|
||||
const items = await Promise.all(
|
||||
list.map((i, item) => {
|
||||
item = $(item);
|
||||
const itemTitle = item.find('a').text();
|
||||
let itemDate = timezone(parseDate(item.find('span').text()), 8);
|
||||
const path = item.find('a').attr('href');
|
||||
const itemUrl = base + path;
|
||||
return ctx.cache.tryGet(itemUrl, async () => {
|
||||
let description = '';
|
||||
const result = await got(itemUrl);
|
||||
const $ = cheerio.load(result.data);
|
||||
if (
|
||||
$('.article_body')
|
||||
.find('div > h4')
|
||||
.text()
|
||||
.match(/发布时间:(.*)编辑:/) !== null
|
||||
) {
|
||||
itemDate = timezone(
|
||||
parseDate(
|
||||
$('.article_body')
|
||||
.find('div > h4')
|
||||
.text()
|
||||
.match(/发布时间:(.*)编辑:/)[1]
|
||||
.trim(),
|
||||
'YYYY年MM月DD日 HH:mm'
|
||||
),
|
||||
8
|
||||
);
|
||||
}
|
||||
description = $('.v_news_content').html().trim();
|
||||
|
||||
return {
|
||||
title: itemTitle,
|
||||
link: itemUrl,
|
||||
pubDate: itemDate,
|
||||
description,
|
||||
};
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '青岛大学 - 后勤管理处通知',
|
||||
link: `${base}index/tzgg.htm`,
|
||||
description: '青岛大学 - 后勤管理处通知',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
module.exports = {
|
||||
'/houqin': ['abc1763613206'],
|
||||
'/jwc': ['abc1763613206'],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,5 +9,13 @@ module.exports = {
|
|||
target: '/qdu/jwc',
|
||||
},
|
||||
],
|
||||
houqin: [
|
||||
{
|
||||
title: '后勤管理处通知',
|
||||
docs: 'https://docs.rsshub.app/routes/university#qing-dao-da-xue',
|
||||
source: ['/tzgg.htm', '/'],
|
||||
target: '/qdu/houqin',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/houqin', require('./houqin'));
|
||||
router.get('/jwc', require('./jwc'));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2199,6 +2199,10 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE\_TL
|
|||
|
||||
<Route author="abc1763613206" example="/qdu/jwc" path="/qdu/jwc" radar="1" anticrawler="1" />
|
||||
|
||||
### 后勤管理处通知 {#qing-dao-da-xue-hou-qin-guan-li-chu-tong-zhi}
|
||||
|
||||
<Route author="abc1763613206" example="/qdu/houqin" path="/qdu/houqin" radar="1" />
|
||||
|
||||
## 清华大学 {#qing-hua-da-xue}
|
||||
|
||||
### 清华大学校内信息发布平台 {#qing-hua-da-xue-qing-hua-da-xue-xiao-nei-xin-xi-fa-bu-ping-tai}
|
||||
|
|
|
|||
Loading…
Reference in New Issue