diff --git a/docs/university.md b/docs/university.md index b1e3aa2da..6a7fdb39a 100644 --- a/docs/university.md +++ b/docs/university.md @@ -1905,6 +1905,18 @@ type 列表: +## 四川农业大学 + +### 招生就业 + + + +| 本科生招生 | 研究生招生 | 毕业生选录指南 | +| ---------- | ---------- | -------------- | +| bkszs | yjszs | bysxlzn | + + + ## 四川职业技术学院 ### 学院公告 diff --git a/lib/v2/sicau/maintainer.js b/lib/v2/sicau/maintainer.js new file mode 100644 index 000000000..22afa8389 --- /dev/null +++ b/lib/v2/sicau/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/zsjy/:category?': ['nczitzk'], +}; diff --git a/lib/v2/sicau/radar.js b/lib/v2/sicau/radar.js new file mode 100644 index 000000000..77868cb6b --- /dev/null +++ b/lib/v2/sicau/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'sicau.edu.cn': { + _name: '', + dky: [ + { + title: '招生就业', + docs: 'https://docs.rsshub.app/university.html#si-chuan-nong-ye-da-xue-zhao-sheng-jiu-ye', + source: ['/'], + target: '/sicau/zsjy/:category?', + }, + ], + }, +}; diff --git a/lib/v2/sicau/router.js b/lib/v2/sicau/router.js new file mode 100644 index 000000000..da91a6da2 --- /dev/null +++ b/lib/v2/sicau/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/zsjy/:category?', require('./zsjy')); +}; diff --git a/lib/v2/sicau/zsjy.js b/lib/v2/sicau/zsjy.js new file mode 100644 index 000000000..e45fb42ab --- /dev/null +++ b/lib/v2/sicau/zsjy.js @@ -0,0 +1,53 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const category = ctx.params.category ?? 'bkszs'; + + const rootUrl = 'https://dky.sicau.edu.cn'; + const currentUrl = `${rootUrl}/zsjy/${category}.htm`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('a.tit') + .map((_, item) => { + item = $(item); + + return { + title: item.text(), + pubDate: parseDate(item.prev().text()), + link: `${rootUrl}${item.attr('href').replace(/\.\./, '/')}`, + }; + }) + .get(); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + content('.v_news_content p').slice(0, 2).remove(); + + item.description = content('.v_news_content').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +};