diff --git a/docs/university.md b/docs/university.md index 6131708a4..6cef8be56 100644 --- a/docs/university.md +++ b/docs/university.md @@ -980,6 +980,12 @@ category 列表: +## 杭州电子科技大学 + +### 计算机学院 - 通知公告 + + + ## 合肥工业大学 ### 通知公告 diff --git a/lib/v2/hdu/cs/index.js b/lib/v2/hdu/cs/index.js new file mode 100644 index 000000000..09ed22b36 --- /dev/null +++ b/lib/v2/hdu/cs/index.js @@ -0,0 +1,57 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +const link = 'https://computer.hdu.edu.cn'; +const host = 'https://computer.hdu.edu.cn/6738/list.htm'; + +const getSingleRecord = async () => { + const res = await got({ + method: 'get', + url: host, + }); + + const $ = cheerio.load(res.data); + const list = $('.posts-list').find('li'); + + return ( + list && + list + .map((index, item) => { + item = $(item); + const dateTxt = item.find('.date').text(); + const date = dateTxt.slice(1, dateTxt.length - 1); + return { + title: item.find('a').text(), + pubDate: parseDate(date), + link: link + item.find('a').attr('href'), + }; + }) + .get() + ); +}; + +module.exports = async (ctx) => { + const items = await getSingleRecord(); + const out = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const response = await got(item.link); + const $ = cheerio.load(response.data); + return { + title: item.title, + link: item.link, + description: $('.wp_articlecontent').html(), + pubDate: item.pubDate, + }; + }) + ) + ); + + ctx.state.data = { + title: '杭电计算机-通知公告', + description: '杭州电子科技大学计算机学院-通知公告', + link: host, + item: out, + }; +}; diff --git a/lib/v2/hdu/maintainer.js b/lib/v2/hdu/maintainer.js new file mode 100644 index 000000000..38a146b76 --- /dev/null +++ b/lib/v2/hdu/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/cs': ['legr4ndk'], +}; diff --git a/lib/v2/hdu/radar.js b/lib/v2/hdu/radar.js new file mode 100644 index 000000000..f2d6b9a89 --- /dev/null +++ b/lib/v2/hdu/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'hdu.edu.cn': { + _name: '杭州电子科技大学', + computer: [ + { + title: '计算机学院 - 通知公告', + docs: 'https://docs.rsshub.app/university.html#hang-zhou-dian-zi-ke-ji-da-xue', + source: '/6738/list.htm', + target: '/hdu/cs', + }, + ], + }, +}; diff --git a/lib/v2/hdu/router.js b/lib/v2/hdu/router.js new file mode 100644 index 000000000..bbb0a7bfc --- /dev/null +++ b/lib/v2/hdu/router.js @@ -0,0 +1,4 @@ +module.exports = function (router) { + // 杭州电子科技大学 + router.get('/cs', require('./cs')); +};