mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 20:27:52 +08:00
feat: add njtech jwc (#2682)
* feat: add njtech jwc * style: format code style
This commit is contained in:
@@ -954,3 +954,9 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet
|
||||
### 数据科学与计算机学院动态
|
||||
|
||||
<Route author="MegrezZhu" example="/sysu/sdcs" path="/sysu/sdcs" />
|
||||
|
||||
## 南京工业大学
|
||||
|
||||
### 南京工业大学教务处
|
||||
|
||||
<Route author="TrumanGu" example="/njtech/jwc" path="/njtech/jwc" />
|
||||
|
||||
@@ -534,6 +534,9 @@ router.get('/seu/radio/academic', require('./routes/universities/seu/radio/acade
|
||||
router.get('/seu/yzb/:type', require('./routes/universities/seu/yzb'));
|
||||
router.get('/seu/cse/:type?', require('./routes/universities/seu/cse'));
|
||||
|
||||
// 南京工业大学
|
||||
router.get('/njtech/jwc', require('./routes/universities/njtech/jwc'));
|
||||
|
||||
// 南京航空航天大学
|
||||
router.get('/nuaa/jwc/:type?', require('./routes/universities/nuaa/jwc/jwc'));
|
||||
router.get('/nuaa/cs/:type?', require('./routes/universities/nuaa/cs/index'));
|
||||
|
||||
56
lib/routes/universities/njtech/jwc.js
Normal file
56
lib/routes/universities/njtech/jwc.js
Normal file
@@ -0,0 +1,56 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const host = 'http://jwb.njtech.edu.cn';
|
||||
|
||||
const link = host + '/index/tzgg.htm';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
headers: {
|
||||
Referer: host,
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const urlList = $('#mainRight li a')
|
||||
.get()
|
||||
.map(
|
||||
(i) =>
|
||||
host +
|
||||
$(i)
|
||||
.attr('href')
|
||||
.replace('..', '')
|
||||
);
|
||||
|
||||
const out = await Promise.all(
|
||||
urlList.map(async (itemUrl) => {
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
const response = await got.get(itemUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
const single = {
|
||||
title: $('#mainRight .title').text(),
|
||||
link: itemUrl,
|
||||
description: $('#vsb_content').html(),
|
||||
pubDate: $('.time')
|
||||
.text()
|
||||
.match(/(\d{4}-\d{2})-\d{2}/)[0],
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
const info = '教务公告';
|
||||
|
||||
ctx.state.data = {
|
||||
title: '南京工业大学教务处 - ' + info,
|
||||
link,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user