feat: add lit xwzx tw and pku rccp mzyt (#2951)

This commit is contained in:
AngUOI
2019-08-29 18:12:54 +08:00
committed by DIYgod
parent 8e7ed9b09a
commit 3fa78af6e2
6 changed files with 193 additions and 6 deletions

View File

@@ -50,6 +50,10 @@ pageClass: routes
</Route> </Route>
### 每周一推 - 中国政治学研究中心
<Route author="AngUOI" example="/pku/rccp/mzyt" path="/universities/pku/rccp/mzyt" />
## 北京航空航天大学 ## 北京航空航天大学
### 北京航空航天大学 ### 北京航空航天大学
@@ -446,6 +450,26 @@ category 列表:
<Route author="AngUOI" example="/lit/jwc" path="/universities/lit/jwc" /> <Route author="AngUOI" example="/lit/jwc" path="/universities/lit/jwc" />
### 新闻中心
<Route author="AngUOI" example="/lit/xwzx/ggtz" path="/universities/lit/xwzx/:name?" :paramsDesc="['默认为 `ggtz`']">
| 公告通知 | 新闻快讯 | 学术信息 | 媒体新闻 |
| -------- | -------- | -------- | -------- |
| ggtz | xwkx | xsxx | mtxw |
</Route>
### 团委
<Route author="AngUOI" example="/lit/tw/tntz" path="/universities/lit/tw/:name?" :paramsDesc="['默认为 `tntz`']">
| 团内通知 | 青年快讯 | 理论学习 |
| -------- | -------- | -------- |
| tntz | qnkx | llxx |
</Route>
## 南昌航空大学 ## 南昌航空大学
### 教务处公告与新闻 ### 教务处公告与新闻

View File

@@ -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/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/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')); router.get('/shmtu/www/:type', require('./routes/universities/shmtu/www'));

View File

@@ -1,11 +1,11 @@
const got = require('@/utils/got'); const got = require('@/utils/got');
const cheerio = require('cheerio'); const cheerio = require('cheerio');
const host = 'http://www.lit.edu.cn/jwc/'; const baseUrl = 'http://www.lit.edu.cn/jwc/';
module.exports = async (ctx) => { module.exports = async (ctx) => {
const response = await got({ const response = await got({
method: 'get', method: 'get',
url: host, url: baseUrl,
}); });
const $ = cheerio.load(response.data); const $ = cheerio.load(response.data);
@@ -21,7 +21,7 @@ module.exports = async (ctx) => {
.find('span') .find('span')
.eq(-1) .eq(-1)
.text(), .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'), title: list.find('a').attr('title'),
description: list.children('.c-con').text(), description: list.children('.c-con').text(),
pubDate: ddate.substring(0, 4) + `-` + ddate.substring(4), 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 = { ctx.state.data = {
title: `洛理教务在线`, title: `洛理教务在线`,
link: host, link: baseUrl,
description: `规范管理 用心服务 欢迎您访问!`, description: `洛阳理工教务在线RSS规范管理 用心服务 欢迎您访问!`,
item: items.map((item) => ({ item: items.map((item) => ({
title: item.title, title: item.title,
description: item.description, description: item.description,

View File

@@ -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();
}
};

View File

@@ -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(),
};
};

View File

@@ -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(),
};
};