mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 23:34:38 +08:00
feat: add dlmu news feed. (#4280)
This commit is contained in:
@@ -191,6 +191,18 @@ pageClass: routes
|
||||
|
||||
</Route>
|
||||
|
||||
## 大连海事大学
|
||||
|
||||
### 新闻网
|
||||
|
||||
<Route author="arjenzhou" example="/dlmu/news/hdyw" path="/dlmu/news/:type" :paramsDesc="['默认为 `hdyw`']">
|
||||
|
||||
| 海大要闻 | 媒体海大 | 综合新闻 | 院系风采 | 海大校报 | 理论园地 | 海大讲坛 | 艺文荟萃 |
|
||||
| :------: | :------: | :------: | :------: | :------: | :------: | :------: | :------: |
|
||||
| hdyw | mthd | zhxw | yxfc | hdxb | llyd | hdjt | ywhc |
|
||||
|
||||
</Route>
|
||||
|
||||
## 电子科技大学
|
||||
|
||||
### 教务处
|
||||
|
||||
@@ -2405,4 +2405,7 @@ router.get('/socialclub/events/:game?', require('./routes/socialclub/events'));
|
||||
// 湖北大学
|
||||
router.get('/hubu/news/:type', require('./routes/universities/hubu/news'));
|
||||
|
||||
// 大连海事大学
|
||||
router.get('/dlmu/news/:type', require('./routes/universities/dlmu/news'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
48
lib/routes/universities/dlmu/news.js
Normal file
48
lib/routes/universities/dlmu/news.js
Normal file
@@ -0,0 +1,48 @@
|
||||
const got = require('@/utils/got');
|
||||
const iconv = require('iconv-lite');
|
||||
const cheerio = require('cheerio');
|
||||
const resolve_url = require('url').resolve;
|
||||
|
||||
const base_url = 'http://news.dlmu.edu.cn';
|
||||
|
||||
const map = {
|
||||
hdyw: '/hdyw.htm',
|
||||
mthd: '/mthd.htm',
|
||||
zhxw: '/zhxw.htm',
|
||||
yxfc: '/yxfc.htm',
|
||||
hdxb: '/hdxb.htm',
|
||||
llyd: '/llyd.htm',
|
||||
hdjt: '/hdjt.htm',
|
||||
ywhc: '/ywhc.htm',
|
||||
};
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type;
|
||||
const link = map.hasOwnProperty(type) ? `${base_url}${map[type]}` : `${base_url}/hdyw.htm`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
responseType: 'buffer',
|
||||
headers: {
|
||||
Referer: base_url,
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(iconv.decode(response.data, 'utf-8'));
|
||||
ctx.state.data = {
|
||||
link: base_url,
|
||||
title: '大连海事大学新闻',
|
||||
item: $('.n-Box .n-right .n-pic-box .n-news dl')
|
||||
.slice(0, 10)
|
||||
.map((_, element) => ({
|
||||
link: resolve_url(base_url, $('dd a', element).attr('href')),
|
||||
title: $('dd a', element).text(),
|
||||
description: $('dd p', element).text(),
|
||||
pubDate: new Date(
|
||||
$('i', element)
|
||||
.text()
|
||||
.slice(1, -1)
|
||||
),
|
||||
}))
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user