diff --git a/docs/university.md b/docs/university.md index 48707a8744..4a0354a7b9 100644 --- a/docs/university.md +++ b/docs/university.md @@ -1409,6 +1409,12 @@ type 列表: +## 四川职业技术学院 + +### 学院公告 + + + ## 天津大学 ### 天津大学教务处 diff --git a/lib/router.js b/lib/router.js index 49c55ebdd1..1e1ffdaffa 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3040,6 +3040,9 @@ router.get('/hfut/tzgg', require('./routes/universities/hfut/tzgg')); // Darwin Awards router.get('/darwinawards/all', require('./routes/darwinawards/articles')); +// 四川职业技术学院 +router.get('/scvtc/xygg', require('./routes/universities/scvtc/xygg')); + // OneJAV router.get('/onejav/:type/:key?', require('./routes/onejav/one')); diff --git a/lib/routes/universities/scvtc/xygg.js b/lib/routes/universities/scvtc/xygg.js new file mode 100644 index 0000000000..0f150d0294 --- /dev/null +++ b/lib/routes/universities/scvtc/xygg.js @@ -0,0 +1,46 @@ +const url = require('url'); +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const currentUrl = 'http://scvtc.edu.cn/ggfw1/xygg.htm'; + const response = await got({ + method: 'get', + url: currentUrl, + }); + const $ = cheerio.load(response.data); + const list = $('div.list_l div ul li') + .map((_, item) => { + item = $(item); + const a = item.find('a[title]'); + return { + title: a.text(), + link: url.resolve(currentUrl, a.attr('href')), + pubDate: new Date(item.find('span.c43271_date').text().split(' ')[0].trim()).toUTCString(), + }; + }) + .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + + item.description = content('#vsb_content').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: '四川职业技术学院 - 学院公告', + link: currentUrl, + item: items, + }; +};