diff --git a/docs/university.md b/docs/university.md index dc99cdb76..7529292a3 100644 --- a/docs/university.md +++ b/docs/university.md @@ -24,6 +24,21 @@ pageClass: routes +## 安徽工业大学 + +### 教务处 + + + +### 学校要闻 + + + +### 计算机学院公告 + + + + ## 安徽农业大学 ### 计算机学院 @@ -1231,6 +1246,12 @@ type 列表: +## 上海理工大学 + +### 教务处 + + + ## 上海立信会计金融学院 ::: warning 注意 diff --git a/lib/router.js b/lib/router.js index 1ec7379fc..0e4fdee8b 100644 --- a/lib/router.js +++ b/lib/router.js @@ -795,6 +795,14 @@ router.get('/ahau/main/:type', require('./routes/universities/ahau/main/index')) // 安徽医科大学研究生学院 router.get('/ahmu/news', require('./routes/universities/ahmu/news')); +// 安徽工业大学 +router.get('/ahut/news', require('./routes/universities/ahut/news')); +router.get('/ahut/jwc', require('./routes/universities/ahut/jwc')); +router.get('/ahut/cstzgg', require('./routes/universities/ahut/cstzgg')); + +// 上海理工大学 +router.get('/usst/jwc', require('./routes/universities/usst/jwc')); + // ifanr router.get('/ifanr/:channel?', require('./routes/ifanr/index')); diff --git a/lib/routes/universities/ahut/cstzgg.js b/lib/routes/universities/ahut/cstzgg.js new file mode 100644 index 000000000..79f1d2dff --- /dev/null +++ b/lib/routes/universities/ahut/cstzgg.js @@ -0,0 +1,64 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = `http://jsjxy.ahut.edu.cn/list.jsp?urltype=tree.TreeTempUrl&wbtreeid=1887`; + const response = await got({ + method: 'get', + url: url, + }); + const $ = cheerio.load(response.data); + $('.clickstyle1022').remove(); + $('td[width = "1%"]').remove(); + $('tr[height = "1"]').remove(); + $('td[colspan="3"]').remove(); + $('.leaderfont47822').remove(); + // ## 获取列表 + const list = $('.winstyle47822 > tbody > tr').get(); + // ## 定义输出的item + const out = await Promise.all( + // ### 遍历列表,筛选出自己想要的内容 + list.map(async (item) => { + const itemSingle = cheerio.load(item); + const title = itemSingle.text().replace(/^[\s]+|[\s]+$/g, ''); + const re = /]*href=['"]([^"]*)['"][^>]*>/g; + let singleUrl = ''; + if (re.exec(itemSingle.html()) !== null) { + singleUrl = RegExp.$1; + } + if (singleUrl.search('http') === -1) { + singleUrl = 'http://jsjxy.ahut.edu.cn' + singleUrl; + } + const cache = await ctx.cache.get(singleUrl); // ### 得到全局中的缓存信息 + // ### 判断缓存是否存在,如果存在即跳过此次获取的信息 + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + // 获取详情页面的介绍 + const detail_response = await got({ + method: 'get', + url: singleUrl, + }); + const $ = cheerio.load(detail_response.data); + const detail_content = $('.contentstyle47853 > div').html(); + // ### 设置 RSS feed item + const single = { + title: title.replace(/(^\s*)|(\s*$)/g, ''), + link: singleUrl, + // author: author, + description: detail_content, + // pubDate: updateDate, + }; + // // ### 设置缓存 + ctx.cache.set(singleUrl, JSON.stringify(single)); + return Promise.resolve(single); + // } + }) + ); + ctx.state.data = { + title: `安徽工业大学 - 计算机学院公告`, + link: 'http://jsjxy.ahut.edu.cn/list.jsp?urltype=tree.TreeTempUrl&wbtreeid=1887', + description: `安徽工业大学 - 计算机学院公告`, + item: out, + }; +}; diff --git a/lib/routes/universities/ahut/jwc.js b/lib/routes/universities/ahut/jwc.js new file mode 100644 index 000000000..77e55deb6 --- /dev/null +++ b/lib/routes/universities/ahut/jwc.js @@ -0,0 +1,62 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = `http://jwc.ahut.edu.cn/list.jsp?urltype=tree.TreeTempUrl&wbtreeid=1082`; + const response = await got({ + method: 'get', + url: url, + }); + const $ = cheerio.load(response.data); + $('tr[height="1"]').remove(); + $('td[width="1%"]').remove(); + $('td[colspan="3"]').remove(); + // ## 获取列表 + const list = $('.winstyle44456 > tbody > tr >td').get(); + // ## 定义输出的item + const out = await Promise.all( + // ### 遍历列表,筛选出自己想要的内容 + list.map(async (item) => { + const itemSingle = cheerio.load(item); + const title = itemSingle.text(); + const re = /]*href=['"]([^"]*)['"][^>]*>/g; + let singleUrl = ''; + if (re.exec(itemSingle.html()) !== null) { + singleUrl = RegExp.$1; + } + if (singleUrl.search('http') === -1) { + singleUrl = 'http://jwc.ahut.edu.cn' + singleUrl; + } + const cache = await ctx.cache.get(singleUrl); // ### 得到全局中的缓存信息 + // ### 判断缓存是否存在,如果存在即跳过此次获取的信息 + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + // 获取详情页面的介绍 + const detail_response = await got({ + method: 'get', + url: singleUrl, + }); + const $ = cheerio.load(detail_response.data); + const detail_content = $('.winstyle44457 > tbody').html(); + // ### 设置 RSS feed item + const single = { + title: title, + link: singleUrl, + // author: author, + description: detail_content, + // pubDate: updateDate, + }; + // // ### 设置缓存 + ctx.cache.set(singleUrl, JSON.stringify(single)); + return Promise.resolve(single); + // } + }) + ); + ctx.state.data = { + title: `安徽工业大学 - 教务处`, + link: 'http://jwc.ahut.edu.cn/list.jsp?urltype=tree.TreeTempUrl&wbtreeid=1082', + description: `安徽工业大学 - 教务处`, + item: out, + }; +}; diff --git a/lib/routes/universities/ahut/news.js b/lib/routes/universities/ahut/news.js new file mode 100644 index 000000000..83aa8e310 --- /dev/null +++ b/lib/routes/universities/ahut/news.js @@ -0,0 +1,64 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = `http://news.ahut.edu.cn/list.jsp?urltype=tree.TreeTempUrl&wbtreeid=1002`; + const response = await got({ + method: 'get', + url: url, + }); + const $ = cheerio.load(response.data); + $('tr[height="26"]').slice(20); + $('td[width="1%"]').remove(); + $('.clickstyle1022').remove(); + $('td[colspan="3"]').remove(); + $('.leaderfont1022').remove(); + // ## 获取列表 + const list = $('.winstyle1022 > tbody > tr > td').get(); + // ## 定义输出的item + const out = await Promise.all( + // ### 遍历列表,筛选出自己想要的内容 + list.map(async (item) => { + const itemSingle = cheerio.load(item); + const title = itemSingle.text().trim(); + const re = /]*href=['"]([^"]*)['"][^>]*>/g; + let singleUrl = ''; + if (re.exec(itemSingle.html()) !== null) { + singleUrl = RegExp.$1; + } + if (singleUrl.search('http') === -1) { + singleUrl = 'http://news.ahut.edu.cn' + singleUrl; + } + const cache = await ctx.cache.get(singleUrl); // ### 得到全局中的缓存信息 + // ### 判断缓存是否存在,如果存在即跳过此次获取的信息 + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + // 获取详情页面的介绍 + const detail_response = await got({ + method: 'get', + url: singleUrl, + }); + const $ = cheerio.load(detail_response.data); + const detail_content = $('.winstyle1023').html(); + // ### 设置 RSS feed item + const single = { + title: title, + link: singleUrl, + // author: author, + description: detail_content, + // pubDate: updateDate, + }; + // // ### 设置缓存 + ctx.cache.set(singleUrl, JSON.stringify(single)); + return Promise.resolve(single); + // } + }) + ); + ctx.state.data = { + title: `安徽工业大学 - 学校要闻`, + link: 'http://news.ahut.edu.cn/list.jsp?urltype=tree.TreeTempUrl&wbtreeid=1002', + description: `安徽工业大学 - 学校要闻`, + item: out, + }; +}; diff --git a/lib/routes/universities/usst/jwc.js b/lib/routes/universities/usst/jwc.js new file mode 100644 index 000000000..f7e2d55f4 --- /dev/null +++ b/lib/routes/universities/usst/jwc.js @@ -0,0 +1,62 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = `http://jwc.usst.edu.cn`; + const response = await got({ + method: 'get', + url: url, + }); + const $ = cheerio.load(response.data); + $('td[width="30px"]').remove(); + $('td[width="195"]').remove(); + // ## 获取列表 + const list = $('.main_shadow > table > tbody > tr > td').get(); + // ## 定义输出的item + const out = await Promise.all( + // ### 遍历列表,筛选出自己想要的内容 + list.map(async (item) => { + const itemSingle = cheerio.load(item); + const title = itemSingle.text(); + const re = /]*href=['"]([^"]*)['"][^>]*>(.*?)<\/a>/g; + let singleUrl = ''; + if (re.exec(itemSingle.html()) !== null) { + singleUrl = RegExp.$1; + } + if (singleUrl.search('http') === -1) { + singleUrl = `http://jwc.usst.edu.cn/` + singleUrl; + } + const cache = await ctx.cache.get(singleUrl); // ### 得到全局中的缓存信息 + // ### 判断缓存是否存在,如果存在即跳过此次获取的信息 + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + // 获取详情页面的介绍 + const detail_response = await got({ + method: 'get', + url: singleUrl, + }); + const $ = cheerio.load(detail_response.data); + const detail_content = $('.wp_articlecontent > .Article_Content').html(); + // ### 设置 RSS feed item + const single = { + title: title, + link: singleUrl, + // author: author, + description: detail_content, + // pubDate: updateDate, + }; + // // ### 设置缓存 + ctx.cache.set(singleUrl, JSON.stringify(single)); + return Promise.resolve(single); + // } + }) + ); + + ctx.state.data = { + title: `上海理工大学 - 教务处`, + link: 'http://jwc.usst.edu.cn/', + description: `上海理工大学 - 教务处`, + item: out, + }; +};