diff --git a/docs/university.md b/docs/university.md index 791f98120..c6e725c41 100644 --- a/docs/university.md +++ b/docs/university.md @@ -2347,6 +2347,18 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS +## 苏州科技大学 + +### 教务处 + + + +| 类型 | 教务动态 | 公告在线 | 选课通知 | +| -- | ---- | ---- | ---- | +| | jwdt | ggzx | xktz | + + + ## 太原师范学院 diff --git a/lib/v2/usts/jwch.js b/lib/v2/usts/jwch.js new file mode 100644 index 000000000..ccc366f50 --- /dev/null +++ b/lib/v2/usts/jwch.js @@ -0,0 +1,56 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +const rootURL = 'http://jwch.usts.edu.cn/index'; + +module.exports = async (ctx) => { + const type = ctx.params.type ?? 'jwdt'; + const url = `${rootURL}/${type}.htm`; + const response = await got(url); + + const $ = cheerio.load(response.data); + const title = $('div.mainWrap.cleafix > div > div.right.fr > div.local.fl > h3').text(); + const list = $('div.list > ul > li') + .map((_index, item) => ({ + title: $(item).find('a').text(), + link: new URL($(item).find('a').attr('href'), rootURL).href, + })) + .get(); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got(item.link); + const content = cheerio.load(detailResponse.data); + + let author = null; + let pubDate = null; + content('div.content-title.fl > i') + .text() + .split('  ') + .forEach((item) => { + if (item.includes('作者:')) { + author = item.split(':')[1]; + } + if (item.includes('时间:')) { + pubDate = item.split(':')[1]; + } + }); + + item.description = content('div#vsb_content').html(); + item.author = author; + item.pubDate = timezone(parseDate(pubDate), +8); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `苏州科技大学 教务处 - ${title}`, + link: url, + item: items, + }; +}; diff --git a/lib/v2/usts/maintainer.js b/lib/v2/usts/maintainer.js new file mode 100644 index 000000000..7ba955b2f --- /dev/null +++ b/lib/v2/usts/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/juch/:type?': ['Fatpandac'], +}; diff --git a/lib/v2/usts/radar.js b/lib/v2/usts/radar.js new file mode 100644 index 000000000..d51cf8fb9 --- /dev/null +++ b/lib/v2/usts/radar.js @@ -0,0 +1,25 @@ +module.exports = { + 'usts.edu.cn': { + _name: '苏州科技大学', + jwch: [ + { + title: '教务动态', + docs: 'https://docs.rsshub.app/university.html#su-zhou-ke-ji-da-xue', + source: ['/jwdt.htm'], + target: '/wsts/jwch/jwdt', + }, + { + title: '公告在线', + docs: 'https://docs.rsshub.app/university.html#su-zhou-ke-ji-da-xue', + source: ['/ggzx.htm'], + target: '/wsts/jwch/ggzx', + }, + { + title: '选课通知', + docs: 'https://docs.rsshub.app/university.html#su-zhou-ke-ji-da-xue', + source: ['/xktz.htm'], + target: '/wsts/jwch/xktz', + }, + ], + }, +}; diff --git a/lib/v2/usts/router.js b/lib/v2/usts/router.js new file mode 100644 index 000000000..4575402d3 --- /dev/null +++ b/lib/v2/usts/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/jwch/:type?', require('./jwch')); +};