mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 21:18:57 +08:00
feat: add 东北大学新闻网 (#3965)
This commit is contained in:
@@ -247,6 +247,18 @@ xskb1 对应 http://www.auto.uestc.edu.cn/index/xskb1.htm
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
## 东北大学
|
||||||
|
|
||||||
|
### 东北大学新闻网
|
||||||
|
|
||||||
|
<Route author="JeasonLau" example="/neu/news/ddyw" path="/neu/news/:type" :paramsDesc="['种类名']">
|
||||||
|
|
||||||
|
| 东大要闻 | 媒体东大 | 通知公告 | 新闻纵横 | 人才培养 | 学术科研 | 英文新闻 | 招生就业 | 考研出国 | 校园文学 | 校友风采 |
|
||||||
|
| -------- | -------- | -------- | -------- | -------: | -------- | -------- | -------- | -------- | -------- | -------- |
|
||||||
|
| ddyw | mtdd | tzgg | xwzh | rcpy | xsky | 217 | zsjy | kycg | xywx | xyfc |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
## 东莞理工学院
|
## 东莞理工学院
|
||||||
|
|
||||||
### 教务处通知
|
### 教务处通知
|
||||||
|
|||||||
@@ -2232,4 +2232,7 @@ router.get('/2048/bbs/:fid', require('./routes/2048/bbs'));
|
|||||||
// Google News
|
// Google News
|
||||||
router.get('/google/news/:category/:locale', require('./routes/google/news'));
|
router.get('/google/news/:category/:locale', require('./routes/google/news'));
|
||||||
|
|
||||||
|
// 东北大学
|
||||||
|
router.get('/neu/news/:type', require('./routes/universities/neu/news'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
63
lib/routes/universities/neu/news.js
Normal file
63
lib/routes/universities/neu/news.js
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
const baseUrl = 'http://neunews.neu.edu.cn';
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const type = ctx.params.type;
|
||||||
|
const newsUrl = `${baseUrl}/${type}/list.htm`;
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: newsUrl,
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = response.data;
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
|
||||||
|
const title = $('title').text();
|
||||||
|
const items = $('.column-news-list > .news_list > .news > .news_title')
|
||||||
|
.slice(0, 10)
|
||||||
|
.children();
|
||||||
|
const results = [];
|
||||||
|
items.each(async (index, item) => {
|
||||||
|
const label = $(item);
|
||||||
|
const title = $(label).attr('title');
|
||||||
|
const url = baseUrl + $(label).attr('href');
|
||||||
|
const description = await ctx.cache.tryGet(url, async () => {
|
||||||
|
const result = await got.get(url);
|
||||||
|
const $ = cheerio.load(result.data);
|
||||||
|
// 处理部分格式
|
||||||
|
$('article')
|
||||||
|
.find('span')
|
||||||
|
.each(function() {
|
||||||
|
const temp = $(this).text();
|
||||||
|
$(this).replaceWith(temp);
|
||||||
|
});
|
||||||
|
$('article')
|
||||||
|
.find('div')
|
||||||
|
.each(function() {
|
||||||
|
const temp = $(this).html();
|
||||||
|
$(this).replaceWith(temp);
|
||||||
|
});
|
||||||
|
$('article')
|
||||||
|
.find('a')
|
||||||
|
.remove();
|
||||||
|
$('article')
|
||||||
|
.find('p')
|
||||||
|
.each(function() {
|
||||||
|
$(this).removeAttr('style');
|
||||||
|
$(this).removeAttr('class');
|
||||||
|
});
|
||||||
|
return $('article').html();
|
||||||
|
});
|
||||||
|
const result = {
|
||||||
|
title: title,
|
||||||
|
description: description,
|
||||||
|
link: url,
|
||||||
|
};
|
||||||
|
results.push(result);
|
||||||
|
});
|
||||||
|
ctx.state.data = {
|
||||||
|
title: title,
|
||||||
|
item: results,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user