diff --git a/docs/university.md b/docs/university.md index 4cd43ea5bb..f62ec8d71f 100644 --- a/docs/university.md +++ b/docs/university.md @@ -50,6 +50,10 @@ pageClass: routes +### 每周一推 - 中国政治学研究中心 + + + ## 北京航空航天大学 ### 北京航空航天大学 @@ -446,6 +450,26 @@ category 列表: +### 新闻中心 + + + +| 公告通知 | 新闻快讯 | 学术信息 | 媒体新闻 | +| -------- | -------- | -------- | -------- | +| ggtz | xwkx | xsxx | mtxw | + + + +### 团委 + + + +| 团内通知 | 青年快讯 | 理论学习 | +| -------- | -------- | -------- | +| tntz | qnkx | llxx | + + + ## 南昌航空大学 ### 教务处公告与新闻 diff --git a/lib/router.js b/lib/router.js index 34a002b2d5..db3bb1d4ca 100644 --- a/lib/router.js +++ b/lib/router.js @@ -531,9 +531,12 @@ router.get('/ju/jwc/:type?', require('./routes/universities/ju/jwc')); // 洛阳理工学院 router.get('/lit/jwc', require('./routes/universities/lit/jwc')); +router.get('/lit/xwzx/:name?', require('./routes/universities/lit/xwzx')); +router.get('/lit/tw/:name?', require('./routes/universities/lit/tw')); // 北京大学 router.get('/pku/eecs/:type?', require('./routes/universities/pku/eecs')); +router.get('/pku/rccp/mzyt', require('./routes/universities/pku/rccp/mzyt')); // 上海海事大学 router.get('/shmtu/www/:type', require('./routes/universities/shmtu/www')); diff --git a/lib/routes/universities/lit/jwc.js b/lib/routes/universities/lit/jwc.js index cfb3353368..a58cb520ae 100644 --- a/lib/routes/universities/lit/jwc.js +++ b/lib/routes/universities/lit/jwc.js @@ -1,11 +1,11 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); -const host = 'http://www.lit.edu.cn/jwc/'; +const baseUrl = 'http://www.lit.edu.cn/jwc/'; module.exports = async (ctx) => { const response = await got({ method: 'get', - url: host, + url: baseUrl, }); const $ = cheerio.load(response.data); @@ -21,7 +21,7 @@ module.exports = async (ctx) => { .find('span') .eq(-1) .text(), - link: host + list.find('a').attr('href'), + link: baseUrl + list.find('a').attr('href'), }); }); @@ -37,14 +37,14 @@ module.exports = async (ctx) => { title: list.find('a').attr('title'), description: list.children('.c-con').text(), pubDate: ddate.substring(0, 4) + `-` + ddate.substring(4), - link: host + list.find('a').attr('href'), + link: baseUrl + list.find('a').attr('href'), }); }); ctx.state.data = { title: `洛理教务在线`, - link: host, - description: `规范管理 用心服务 欢迎您访问!`, + link: baseUrl, + description: `洛阳理工教务在线RSS,规范管理 用心服务 欢迎您访问!`, item: items.map((item) => ({ title: item.title, description: item.description, diff --git a/lib/routes/universities/lit/tw.js b/lib/routes/universities/lit/tw.js new file mode 100644 index 0000000000..37abc325ac --- /dev/null +++ b/lib/routes/universities/lit/tw.js @@ -0,0 +1,69 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const url = require('url'); + +const baseUrl = 'http://www.lit.edu.cn/tw/'; + +const nameProps = { + tntz: '团内通知', + qnkx: '青年快讯', + llxx: '理论学习', +}; + +module.exports = async (ctx) => { + const name = ctx.params.name || 'tntz'; + const u = url.resolve(baseUrl, `${name}.htm`); + const response = await got({ + method: 'get', + url: u, + }); + + const $ = cheerio.load(response.data); + + ctx.state.data = { + title: `${nameProps[name]} - 洛理团委`, + link: u, + description: `洛阳理工学院团委 - ${nameProps[name]}`, + }; + + if (name === 'llxx') { + ctx.state.data.item = $('li.newslist') + .map((index, item) => ({ + title: $(item) + .find('a.type_one') + .text(), + description: $(item) + .find('li.desc') + .text() + .trim(), + pubDate: $(item) + .find('small') + .first() + .text() + .replace(/\//g, '-'), + link: + baseUrl + + $(item) + .find('a.type_one') + .attr('href'), + })) + .get(); + } else { + ctx.state.data.item = $('ul.caselist li') + .map((index, item) => ({ + title: $(item) + .find('a') + .text(), + description: '', + pubDate: $(item) + .find('span.time') + .text(), + link: + baseUrl + + $(item) + .find('a') + .attr('href'), + })) + .get(); + } +}; diff --git a/lib/routes/universities/lit/xwzx.js b/lib/routes/universities/lit/xwzx.js new file mode 100644 index 0000000000..d3f4c41d1c --- /dev/null +++ b/lib/routes/universities/lit/xwzx.js @@ -0,0 +1,51 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const url = require('url'); + +const host = 'http://www.lit.edu.cn/'; +const baseUrl = 'http://www.lit.edu.cn/xwzx/'; + +const nameProps = { + ggtz: '公告通知', + xwkx: '新闻快讯', + xsxx: '学术信息', + mtxw: '媒体新闻', +}; + +module.exports = async (ctx) => { + const name = ctx.params.name || 'ggtz'; + const u = url.resolve(baseUrl, `${name}.htm`); + const response = await got({ + method: 'get', + url: u, + }); + const $ = cheerio.load(response.data); + ctx.state.data = { + title: `${nameProps[name]} - 洛理新闻中心`, + link: u, + description: `洛阳理工学院新闻中心 - ${nameProps[name]}`, + item: $('li.list_item') + .map((index, item) => ({ + title: $(item) + .find('a') + .attr('title'), + description: '', + author: $(item) + .find('.Article_PublishDate') + .text() + .replace(/\d{4}年\d{2}月\d{2}日/g, '') + .replace(',', '') + .trim(), + pubDate: $(item) + .find('.Article_PublishDate') + .text() + .match(/[A-Za-z0-9_]+/g) + .join('-'), + link: $(item) + .find('a') + .attr('href') + .replace('../', host), + })) + .get(), + }; +}; diff --git a/lib/routes/universities/pku/rccp/mzyt.js b/lib/routes/universities/pku/rccp/mzyt.js new file mode 100644 index 0000000000..c395903b07 --- /dev/null +++ b/lib/routes/universities/pku/rccp/mzyt.js @@ -0,0 +1,40 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const baseUrl = 'http://www.rccp.pku.edu.cn/mzyt/'; + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: baseUrl, + }); + + const $ = cheerio.load(response.data); + ctx.state.data = { + title: `每周一推 - 北京大学中国政治学研究中心`, + link: baseUrl, + description: `北京大学中国政治学研究中心,北大中国政治学研究中心,北大政治学研究中心,中国政治学研究中心,政治学研究中心,政治学,北大政治学,北京大学,俞可平 + 北京大学中国政治学研究中心官方网站:www.rccp.pku.edu.cn 。 + 北京大学中国政治学研究中心微信公众平台:“北大政治学”(微信号:PKURCCP)`, + item: $('li.list') + .map((index, item) => ({ + title: $(item) + .find('a') + .text() + .trim(), + description: '', + pubDate: $(item) + .find('span') + .first() + .text() + .match(/\d{4}-\d{2}-\d{2}/g)[0], + + link: + baseUrl + + $(item) + .find('a') + .attr('href'), + })) + .get(), + }; +};