feat(route): add descriptions for nwafu (#13067)

* feat(route): add descriptions for nwafu

docs: update the docs
scriptsformat scripts
refactor: migrate to v2

* Create radar.js

* Update radar.js

* feat(route): fix the route

* Update website/docs/routes/university.md

* Update website/docs/routes/university.md

* Update all.js

* Update all.js

* Update lib/v2/nwafu/all.js

* Update all.js

---------
This commit is contained in:
karinido 2023-08-18 19:37:02 +08:00 committed by GitHub
parent d73cf524a2
commit 4e79abd39d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 91 additions and 291 deletions

View File

@ -336,17 +336,6 @@ router.get('/sctu/xgxy/:id', lazyloadRouteHandler('./routes/universities/sctu/in
router.get('/sctu/jwc/:type?', lazyloadRouteHandler('./routes/universities/sctu/jwc/index'));
router.get('/sctu/jwc/:type/:id', lazyloadRouteHandler('./routes/universities/sctu/jwc/context'));
// 西北农林科技大学
router.get('/nwafu/news', lazyloadRouteHandler('./routes/universities/nwafu/news'));
router.get('/nwafu/jiaowu', lazyloadRouteHandler('./routes/universities/nwafu/jiaowu'));
router.get('/nwafu/gs', lazyloadRouteHandler('./routes/universities/nwafu/gs'));
router.get('/nwafu/lib', lazyloadRouteHandler('./routes/universities/nwafu/lib'));
router.get('/nwafu/nic', lazyloadRouteHandler('./routes/universities/nwafu/nic'));
router.get('/nwafu/54youth', lazyloadRouteHandler('./routes/universities/nwafu/54youth'));
router.get('/nwafu/jcc', lazyloadRouteHandler('./routes/universities/nwafu/jcc'));
router.get('/nwafu/yjshy', lazyloadRouteHandler('./routes/universities/nwafu/yjshy'));
router.get('/nwafu/cie', lazyloadRouteHandler('./routes/universities/nwafu/cie'));
// 云南大学
router.get('/ynu/grs/zytz', lazyloadRouteHandler('./routes/universities/ynu/grs/zytz'));
router.get('/ynu/grs/qttz/:category', lazyloadRouteHandler('./routes/universities/ynu/grs/qttz'));

View File

@ -1,28 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://54youth.nwsuaf.edu.cn/wjtz/tzgg/index.htm',
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('.news-list > li');
ctx.state.data = {
title: '西北农林科技大学 - 团委公告',
link: 'https://54youth.nwsuaf.edu.cn/wjtz/tzgg/index.htm',
item:
list &&
list
.map((index, item) => {
item = $(item);
return { title: item.find('li a').text(), description: item.find('li a').text(), pubDate: parseDate(item.find('span').text(), 'YYYY/MM/DD'), link: item.find('li a').attr('href') };
})
.get(),
};
};

View File

@ -1,28 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://cie.nwafu.edu.cn/dtytz/tzgg/index.htm',
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('#sort > dd > ul > li');
ctx.state.data = {
title: '西北农林科技大学 - 信工学院公告',
link: 'https://cie.nwafu.edu.cn/dtytz/tzgg/index.htm',
item:
list &&
list
.map((index, item) => {
item = $(item);
return { title: item.find('li a').text(), description: item.find('li a').text(), pubDate: parseDate(item.find('span').text(), 'YYYY/MM/DD'), link: item.find('li a').attr('href') };
})
.get(),
};
};

View File

@ -1,28 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://gs.nwsuaf.edu.cn/tzggB/index.htm',
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('#sort > dd > .list > li');
ctx.state.data = {
title: '西北农林科技大学 - 后勤公告',
link: 'https://gs.nwsuaf.edu.cn/tzggB/index.htm',
item:
list &&
list
.map((index, item) => {
item = $(item);
return { title: item.find('li a').text(), description: item.find('li a').text(), pubDate: parseDate(item.find('span').text(), 'YYYY/MM/DD'), link: item.find('li a').attr('href') };
})
.get(),
};
};

View File

@ -1,28 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://jcc.nwafu.edu.cn/tzgg/index.htm',
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('#sort > dd > .list > li');
ctx.state.data = {
title: '西北农林科技大学 - 计财处公告',
link: 'https://jcc.nwafu.edu.cn/tzgg/index.htm',
item:
list &&
list
.map((index, item) => {
item = $(item);
return { title: item.find('li a').text(), description: item.find('li a').text(), pubDate: parseDate(item.find('span').text(), 'YYYY/MM/DD'), link: item.find('li a').attr('href') };
})
.get(),
};
};

View File

@ -1,28 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://jiaowu.nwafu.edu.cn/tzggB/index.htm',
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('.list-i > ul > li');
ctx.state.data = {
title: '西北农林科技大学 - 教务公告',
link: 'https://jiaowu.nwafu.edu.cn/tzggB/index.htm',
item:
list &&
list
.map((index, item) => {
item = $(item);
return { title: item.find('li a').text(), description: item.find('li a').text(), pubDate: parseDate(item.find('span').text(), 'YYYY/MM/DD'), link: item.find('li a').attr('href') };
})
.get(),
};
};

View File

@ -1,28 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://lib.nwafu.edu.cn/gg/index.htm',
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('.articleList2.articleList > ul > li');
ctx.state.data = {
title: '西北农林科技大学 - 图书馆公告',
link: 'https://lib.nwafu.edu.cn/gg/index.htm',
item:
list &&
list
.map((index, item) => {
item = $(item);
return { title: item.find('li a').text(), description: item.find('li a').text(), pubDate: parseDate(item.find('span').text().slice(1, -1), 'YYYY/MM/DD'), link: item.find('li a').attr('href') };
})
.get(),
};
};

View File

@ -1,28 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://news.nwafu.edu.cn/xnxw/index.htm',
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('.list01 > li');
ctx.state.data = {
title: '西北农林科技大学 - 校园新闻',
link: 'https://news.nwafu.edu.cn/xnxw/index.htm',
item:
list &&
list
.map((index, item) => {
item = $(item);
return { title: item.find('li a').text(), description: item.find('li a').text(), pubDate: parseDate(item.find('span').text(), 'YYYY/MM/DD'), link: item.find('li a').attr('href') };
})
.get(),
};
};

View File

@ -1,28 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://nic.nwafu.edu.cn/tzgg1/index.htm',
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('#sort > dd > .list > li');
ctx.state.data = {
title: '西北农林科技大学 - 网教中心公告',
link: 'https://nic.nwafu.edu.cn/tzgg1/index.htm',
item:
list &&
list
.map((index, item) => {
item = $(item);
return { title: item.find('li a').text(), description: item.find('li a').text(), pubDate: parseDate(item.find('span').text(), 'YYYY/MM/DD'), link: item.find('li a').attr('href') };
})
.get(),
};
};

View File

@ -1,28 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://yjshy.nwafu.edu.cn/tzgg/index.htm',
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('.sort_rightcont > ul > li');
ctx.state.data = {
title: '西北农林科技大学 - 研究生院公告',
link: 'https://yjshy.nwafu.edu.cn/tzgg/index.htm',
item:
list &&
list
.map((index, item) => {
item = $(item);
return { title: item.find('li a').text(), description: item.find('li a').text(), pubDate: parseDate(item.find('span').text().slice(1, -1), 'YYYY/MM/DD'), link: item.find('li a').attr('href') };
})
.get(),
};
};

41
lib/v2/nwafu/all.js Normal file
View File

@ -0,0 +1,41 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const { nwafuMap } = require('./utils');
module.exports = async (ctx) => {
const { type = 'jiaowu' } = ctx.params;
const response = await got.get(nwafuMap.get(type)[0]);
const $ = cheerio.load(response.data);
const list = $(nwafuMap.get(type)[1])
.map((index, ele) => {
const itemTitle = $(ele).find(nwafuMap.get(type)[2]).text();
const itemPubDate = parseDate($(ele).find('span').text(), 'YYYY/MM/DD');
const link = new URL($(ele).find(nwafuMap.get(type)[2]).attr('href'), nwafuMap.get(type)[0]);
return {
title: itemTitle,
pubDate: itemPubDate,
link: link.toString(),
};
})
.get();
const out = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got.get(item.link);
const $ = cheerio.load(detailResponse.data);
item.description = $(nwafuMap.get(type)[3]).html();
return item;
})
)
);
ctx.state.data = {
title: nwafuMap.get(type)[4],
link: nwafuMap.get(type)[0],
description: nwafuMap.get(type)[4],
item: out,
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/:type?': ['karinido'],
};

13
lib/v2/nwafu/radar.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
'nwafu.edu.cn': {
_name: '西北农林科技大学',
'.': [
{
title: '校园要闻',
docs: 'https://docs.rsshub.app/routes/university#xi-bei-nong-lin-ke-ji-da-xue-xiao-yuan-yao-wen',
source: ['/tzgg.htm', '/'],
target: '/nwafu/jiaowu',
},
],
},
};

3
lib/v2/nwafu/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/:type?', require('./all'));
};

25
lib/v2/nwafu/utils.js Normal file
View File

@ -0,0 +1,25 @@
const libValue = ['https://lib.nwafu.edu.cn/gg/', '.pageList ul li', 'li a', '.pageArticle', `西北农林科技大学图书馆通知公告`];
const youthValue = ['https://54youth.nwsuaf.edu.cn/twsy/tzgg//', 'section ul li', 'li a', 'article', `共青团西北农林科技大学委员会通知公告`];
const cieValue = ['https://cie.nwsuaf.edu.cn/dtytz/tzgg/', 'ul.list li', 'li a', '.article', `西北农林科技大学信息工程学院通知公告`];
const gsValue = ['https://gs.nwsuaf.edu.cn/tzggB/', 'ul.list li', 'li a', '.content', `西北农林科技大学后勤管理处通知公告`];
const jccValue = ['https://jcc.nwsuaf.edu.cn/tzgg/', 'ul.list li', 'li a', '.article', `西北农林科技大学计划财务处通知公告`];
const jiaowuValue = ['https://jiaowu.nwsuaf.edu.cn/tzggB/', '.list-i ul li', 'li a', 'article', `西北农林科技大学教务通知公告`];
const newsValue = ['https://news.nwafu.edu.cn/yxxw/', 'ul.NWAFU-list01 li', 'li a', '.pageArticle', `西北农林科技大学新闻网聚焦院处`];
const nicValue = ['https://nic.nwsuaf.edu.cn/tzgg1/', 'ul.list li', 'li a', '.article', `西北农林科技大学信息化管理处通知公告`];
const yjshyValue = ['https://yjshy.nwafu.edu.cn/tzgg/', '.sort_rightcont ul li', 'li a', '.cont', `西北农林科技大学研究生院通知公告`];
const nwafuMap = new Map([
['lib', libValue],
['youth', youthValue],
['cie', cieValue],
['gs', gsValue],
['jcc', jccValue],
['jiaowu', jiaowuValue],
['news', newsValue],
['nic', nicValue],
['yjshy', yjshyValue],
]);
module.exports = {
nwafuMap,
};

View File

@ -3241,39 +3241,17 @@ paramsDesc={['公告类型,详见表格']}>
### 校园要闻 {#xi-bei-nong-lin-ke-ji-da-xue-xiao-yuan-yao-wen}
<Route author="dingyx99" example="/nwafu/news" path="/nwafu/news" />
<Route author="dingyx99 karinido" example="/nwafu/lib" path="/nwafu/:type?" paramsDesc={['默认为 `jiaowu`']}>
### 教务公告 {#xi-bei-nong-lin-ke-ji-da-xue-jiao-wu-gong-gao}
通知类别
<Route author="dingyx99" example="/nwafu/jiaowu" path="/nwafu/jiaowu" />
### 后勤公告 {#xi-bei-nong-lin-ke-ji-da-xue-hou-qin-gong-gao}
| 图书馆 | 共青团团委 | 信工学院 | 后勤管理处 | 计划财务处 | 教务处 | 新闻网 | 信息化管理处 | 研究生院 |
| -------- | -------- | -------- | -------- | ------------ | -------- | -------- | -------- | -------- |
| lib | youth | cie | gs | jcc | jiaowu | news | nic | yjshy |
<Route author="dingyx99" example="/nwafu/gs" path="/nwafu/gs" />
</Route>
### 图书馆公告 {#xi-bei-nong-lin-ke-ji-da-xue-tu-shu-guan-gong-gao}
<Route author="dingyx99" example="/nwafu/lib" path="/nwafu/lib" />
### 网教中心公告 {#xi-bei-nong-lin-ke-ji-da-xue-wang-jiao-zhong-xin-gong-gao}
<Route author="dingyx99" example="/nwafu/nic" path="/nwafu/nic" />
### 团委公告 {#xi-bei-nong-lin-ke-ji-da-xue-tuan-wei-gong-gao}
<Route author="dingyx99" example="/nwafu/54youth" path="/nwafu/54youth" />
### 计财处公告 {#xi-bei-nong-lin-ke-ji-da-xue-ji-cai-chu-gong-gao}
<Route author="dingyx99" example="/nwafu/jcc" path="/nwafu/jcc" />
### 研究生院公告 {#xi-bei-nong-lin-ke-ji-da-xue-yan-jiu-sheng-yuan-gong-gao}
<Route author="dingyx99" example="/nwafu/yjshy" path="/nwafu/yjshy" />
### 信息工程学院公告 {#xi-bei-nong-lin-ke-ji-da-xue-xin-xi-gong-cheng-xue-yuan-gong-gao}
<Route author="dingyx99" example="/nwafu/cie" path="/nwafu/cie" />
## 西南财经大学 {#xi-nan-cai-jing-da-xue}