feat: add 哈尔滨工业大学(威海)通知公告 (#4825)
This commit is contained in:
@@ -551,6 +551,12 @@ category 列表:
|
||||
部分文章需要经过统一身份认证后才能阅读全文。
|
||||
:::
|
||||
|
||||
## 哈尔滨工业大学(威海)
|
||||
|
||||
### 今日工大 - 通知公告
|
||||
|
||||
<Route author="raptazure" example="/hitwh/today" path="hitwh/today" />
|
||||
|
||||
## 河南大学
|
||||
|
||||
### 河南大学
|
||||
|
||||
@@ -585,6 +585,9 @@ router.get('/nuaa/yjsy/:type?', require('./routes/universities/nuaa/yjsy/yjsy'))
|
||||
router.get('/hit/jwc', require('./routes/universities/hit/jwc'));
|
||||
router.get('/hit/today/:category', require('./routes/universities/hit/today'));
|
||||
|
||||
// 哈尔滨工业大学(威海)
|
||||
router.get('/hitwh/today', require('./routes/universities/hitwh/today'));
|
||||
|
||||
// 上海科技大学
|
||||
router.get('/shanghaitech/activity', require('./routes/universities/shanghaitech/activity'));
|
||||
router.get('/shanghaitech/sist/activity', require('./routes/universities/shanghaitech/sist/activity'));
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
|
||||
const baseUrl = 'http://today.hitwh.edu.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got.get(`${baseUrl}/1024/list.htm`);
|
||||
const { data } = response;
|
||||
const $ = cheerio.load(data);
|
||||
const type = (filename) => filename.split('.').pop();
|
||||
const links = $('#righ_list ul li')
|
||||
.map((_, el) => ({
|
||||
pubDate: new Date($(el).find('font').text().substr(-10, 10)).toUTCString(),
|
||||
link: url.resolve(baseUrl, $('a', el).attr('href')),
|
||||
title: $(el).find('a').text(),
|
||||
}))
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: '哈尔滨工业大学(威海)通知公告',
|
||||
link: `${baseUrl}/1024/list.htm`,
|
||||
item: await Promise.all(
|
||||
links.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
if (type(item.link) === 'htm') {
|
||||
const { data } = await got.get(item.link);
|
||||
const $ = cheerio.load(data);
|
||||
item.description =
|
||||
$('div.wp_articlecontent').html() &&
|
||||
$('div.wp_articlecontent')
|
||||
.html()
|
||||
.replace(/src="\//g, `src="${url.resolve(baseUrl, '.')}`)
|
||||
.replace(/href="\//g, `href="${url.resolve(baseUrl, '.')}`)
|
||||
.trim();
|
||||
return item;
|
||||
} else {
|
||||
// file to download
|
||||
item.description = '此链接为文件,点击以下载';
|
||||
return item;
|
||||
}
|
||||
})
|
||||
)
|
||||
),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user