mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-16 02:42:57 +08:00
Add 哈尔滨工业大学教务处通知公告 (#634)
This commit is contained in:
@@ -363,6 +363,16 @@ RSSHub 同时支持 RSS 2.0、Atom 和 [JSON Feed](https://jsonfeed.org/) 输出
|
||||
|
||||
参数: 无
|
||||
|
||||
### 哈尔滨工业大学
|
||||
|
||||
#### 哈尔滨工业大学教务处通知公告 <Author uid="lty96117"/>
|
||||
|
||||
举例: <https://rsshub.app/hit/jwc>
|
||||
|
||||
路由: `/hit/jwc`
|
||||
|
||||
参数: 无
|
||||
|
||||
### 上海科技大学
|
||||
|
||||
#### 信息科技与技术学院活动 <Author uid="HenryQW"/>
|
||||
|
||||
@@ -462,6 +462,9 @@ router.get('/dpu/wlfw/news/:type?', require('./routes/universities/dpu/wlfw/news
|
||||
// 东南大学
|
||||
router.get('/seu/radio/academic', require('./routes/universities/seu/radio/academic'));
|
||||
|
||||
// 哈尔滨工业大学
|
||||
router.get('/hit/jwc', require('./routes/universities/hit/jwc'));
|
||||
|
||||
// 上海科技大学
|
||||
router.get('/shanghaitech/sist/activity', require('./routes/universities/shanghaitech/sist/activity'));
|
||||
|
||||
|
||||
60
routes/universities/hit/jwc.js
Normal file
60
routes/universities/hit/jwc.js
Normal file
@@ -0,0 +1,60 @@
|
||||
const axios = require('axios');
|
||||
const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
|
||||
const baseUrl = 'http://jwc.hit.edu.cn';
|
||||
const type = (filename) => filename.split('.').pop();
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await axios.get(`${baseUrl}/2591/list.htm`);
|
||||
|
||||
const { data } = response;
|
||||
const $ = cheerio.load(data);
|
||||
const links = $('.news_list li')
|
||||
.map((i, el) => ({
|
||||
pubDate: new Date(
|
||||
$('span.fbll', el)
|
||||
.children()
|
||||
.first()
|
||||
.text()
|
||||
.replace('[', '')
|
||||
),
|
||||
link: url.resolve(baseUrl, $('a', el).attr('href')),
|
||||
title: $('a', el).attr('title'),
|
||||
}))
|
||||
.get();
|
||||
|
||||
const item = await Promise.all(
|
||||
[...links].slice(0, 10).map(async ({ pubDate, link, title }) => {
|
||||
if (type(link) === 'htm') {
|
||||
const { data } = await axios.get(link);
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
const author = $('p.arti_metas>span:nth-child(3)')
|
||||
.text()
|
||||
.trim();
|
||||
const description =
|
||||
$('div.wp_articlecontent').html() &&
|
||||
$('div.wp_articlecontent')
|
||||
.html()
|
||||
.replace(/src="\//g, `src="${url.resolve(baseUrl, '.')}`)
|
||||
.replace(/href="\//g, `href="${url.resolve(baseUrl, '.')}`)
|
||||
.trim();
|
||||
// check for some bug links.
|
||||
if (!description) {
|
||||
return;
|
||||
}
|
||||
return Promise.resolve({ pubDate, author, link, title, description });
|
||||
} else {
|
||||
// file to download
|
||||
return Promise.resolve({ pubDate, link, title, description: '此链接为文件,点击以下载' });
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '哈尔滨工业大学教务处通知公告',
|
||||
link: `${baseUrl}/2591/list.htm`,
|
||||
item: item.filter((x) => x),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user