Skip to content

Commit

Permalink
feat(route): Add qdu houqin (DIYgod#14515)
Browse files Browse the repository at this point in the history
* feat(route): Add qdu houqin

* feat(route): qdu houqin - more accurate time

* fix: alphabetical order

* fix: unnecessary condition

---------
  • Loading branch information
abc1763613206 authored Feb 21, 2024
1 parent 88a594e commit 0d47d01
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
63 changes: 63 additions & 0 deletions lib/v2/qdu/houqin.js
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions lib/v2/qdu/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
'/houqin': ['abc1763613206'],
'/jwc': ['abc1763613206'],
};
8 changes: 8 additions & 0 deletions lib/v2/qdu/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 change: 1 addition & 0 deletions lib/v2/qdu/router.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = (router) => {
router.get('/houqin', require('./houqin'));
router.get('/jwc', require('./jwc'));
};
4 changes: 4 additions & 0 deletions website/docs/routes/university.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 0d47d01

Please sign in to comment.