mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-19 06:38:55 +08:00
feat(route): add 华南理工大学电子与信息学院 - 新闻速递 (#7772)
Co-authored-by: auto-bot-ty <auto-bot-ty@git@com> Co-authored-by: SettingDust <settingdust@gmail.com>
This commit is contained in:
@@ -973,6 +973,14 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
|
||||
|
||||
<Route author="railzy" example="/scut/scet/notice" path="/scut/scet/notice" />
|
||||
|
||||
### 电子与信息学院 - 新闻速递
|
||||
|
||||
<Route author="auto-bot-ty" example="/scut/seie/news_center" path="/scut/seie/news_center" />
|
||||
|
||||
::: warning 注意
|
||||
由于学院官网对非大陆 IP 的访问存在限制,需自行部署。
|
||||
:::
|
||||
|
||||
## 华南师范大学
|
||||
|
||||
### 软件学院通知公告
|
||||
|
||||
@@ -3237,6 +3237,9 @@ router.get('/scvtc/xygg', require('./routes/universities/scvtc/xygg'));
|
||||
// 华南理工大学土木与交通学院
|
||||
router.get('/scut/scet/notice', require('./routes/universities/scut/scet/notice'));
|
||||
|
||||
// 华南理工大学电子与信息学院
|
||||
router.get('/scut/seie/news_center', require('./routes/universities/scut/seie/news_center'));
|
||||
|
||||
// OneJAV
|
||||
router.get('/onejav/:type/:key?', require('./routes/onejav/one'));
|
||||
|
||||
|
||||
58
lib/routes/universities/scut/seie/news_center.js
Normal file
58
lib/routes/universities/scut/seie/news_center.js
Normal file
@@ -0,0 +1,58 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://www2.scut.edu.cn';
|
||||
const url = `${rootUrl}/ee/16285/list.htm`;
|
||||
const response = await got.get(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.news_ul li');
|
||||
const articleList = list
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const titleElement = item.find('.news_title a');
|
||||
return {
|
||||
title: titleElement.attr('title'),
|
||||
link: titleElement.attr('href'),
|
||||
pubDate: parseDate(item.find('.news_meta').text(), 'YYYY-MM-DD'),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
articleList.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: `${rootUrl}${item.link}`,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data, { decodeEntities: false });
|
||||
|
||||
content('.wp_articlecontent *').each((_, child) => {
|
||||
const childElem = content(child);
|
||||
childElem.removeAttr('style');
|
||||
childElem.removeAttr('lang');
|
||||
childElem.removeAttr('original-src');
|
||||
childElem.removeAttr('sudyfile-attr');
|
||||
childElem.removeAttr('data-layer');
|
||||
if ((!childElem.text().replace('\n', '').trim().length && !childElem.has('img')) || childElem.attr('name') === '_GoBack' || childElem.is('style')) {
|
||||
childElem.remove();
|
||||
}
|
||||
});
|
||||
|
||||
const contentHTML = content('.wp_articlecontent').html();
|
||||
item.description = contentHTML.replace(/^(<br>)+|(<br>)+$/g, '').trim();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '华南理工大学电子与信息学院 - 新闻速递',
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user