From acb07f82b2ab5d26b04f10a826a4303623a1ee59 Mon Sep 17 00:00:00 2001 From: Colin-XKL <49122401+Colin-XKL@users.noreply.github.com> Date: Fri, 15 Jan 2021 10:40:27 +0800 Subject: [PATCH] Add CQUT news (#6700) * add CQUT news * add CQUT libnews --- assets/radar-rules.js | 17 +++++++++++ docs/university.md | 10 ++++++ lib/router.js | 4 +++ lib/routes/universities/cqut/cqut-libnews.js | 32 ++++++++++++++++++++ lib/routes/universities/cqut/cqut-news.js | 31 +++++++++++++++++++ 5 files changed, 94 insertions(+) create mode 100644 lib/routes/universities/cqut/cqut-libnews.js create mode 100644 lib/routes/universities/cqut/cqut-news.js diff --git a/assets/radar-rules.js b/assets/radar-rules.js index 99a84e6044..3c35138932 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -2590,4 +2590,21 @@ }, ], }, + 'cqut.edu.cn': { + _name: '重庆理工大学', + tz: [ + { + title: '通知', + docs: 'https://docs.rsshub.app/university.html#chong-qing-li-gong-da-xue', + source: '/*', + }, + ], + lib: [ + { + title: '图书馆通知', + docs: 'https://docs.rsshub.app/university.html#chong-qing-li-gong-da-xue', + source: '/*', + }, + ], + }, }); diff --git a/docs/university.md b/docs/university.md index a30c3b731d..f4f33ba5ae 100644 --- a/docs/university.md +++ b/docs/university.md @@ -2194,6 +2194,16 @@ type 列表: +## 重庆理工大学 + +### 学校通知 + + + +### 图书馆通知 + + + ## 中山大学 ### 数据科学与计算机学院动态 diff --git a/lib/router.js b/lib/router.js index 5fdfe7655d..b2b8901329 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3878,4 +3878,8 @@ router.get('/newzmz/:category?', require('./routes/newzmz/index')); // Phrack Magazine router.get('/phrack', require('./routes/phrack/index')); +// CQUT News +router.get('/cqut/news', require('./routes/universities/cqut/cqut-news')); +router.get('/cqut/libnews', require('./routes/universities/cqut/cqut-libnews')); + module.exports = router; diff --git a/lib/routes/universities/cqut/cqut-libnews.js b/lib/routes/universities/cqut/cqut-libnews.js new file mode 100644 index 0000000000..deb42f135f --- /dev/null +++ b/lib/routes/universities/cqut/cqut-libnews.js @@ -0,0 +1,32 @@ +const cheerio = require('cheerio'); +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: 'https://libnews.cqut.edu.cn/', + }); + + const data = response.data; + + const $ = cheerio.load(data); // 使用 cheerio 加载返回的 HTML + const list = $('#infoList').find('div'); + + ctx.state.data = { + title: '重庆理工大学中山图书馆资讯', + link: 'https://libnews.cqut.edu.cn', + item: + list && + list + .map((index, item) => { + item = $(item); + return { + title: item.find('a').text().trim(), + description: item.find('a').text().trim(), + link: item.find('a').attr('href'), + pubDate: new Date(item.find('span').text().trim().slice(1, -1)).toUTCString(), + }; + }) + .get(), + }; +}; diff --git a/lib/routes/universities/cqut/cqut-news.js b/lib/routes/universities/cqut/cqut-news.js new file mode 100644 index 0000000000..f25eae7866 --- /dev/null +++ b/lib/routes/universities/cqut/cqut-news.js @@ -0,0 +1,31 @@ +const cheerio = require('cheerio'); +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: 'https://tz.cqut.edu.cn/', + }); + + const data = response.data; + const $ = cheerio.load(data); // 使用 cheerio 加载返回的 HTML + const list = $('#container').find('.record'); + + ctx.state.data = { + title: 'CQUT', + link: 'https://tz.cqut.edu.cn/', + item: + list && + list + .map((index, item) => { + item = $(item); + return { + title: item.find('a').attr('title'), + description: item.find('a').attr('title'), + link: item.find('a').attr('href'), + pubDate: new Date(item.find('.date').text().trim()).toUTCString(), + }; + }) + .get(), + }; +};