diff --git a/docs/university.md b/docs/university.md index 298dba03a2..c36870db03 100644 --- a/docs/university.md +++ b/docs/university.md @@ -954,3 +954,9 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet ### 数据科学与计算机学院动态 + +## 南京工业大学 + +### 南京工业大学教务处 + + diff --git a/lib/router.js b/lib/router.js index 6cb7289de5..2f32d6e440 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/universities/njtech/jwc.js b/lib/routes/universities/njtech/jwc.js new file mode 100644 index 0000000000..efce1e61e8 --- /dev/null +++ b/lib/routes/universities/njtech/jwc.js @@ -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, + }; +};