feat(route): add 四川农业大学招生就业 (#8557)
This commit is contained in:
parent
27d85b2226
commit
ff1cc11929
|
|
@ -1905,6 +1905,18 @@ type 列表:
|
|||
|
||||
<Route author="talenHuang" example="/sctu/jwc/13/645" path="/sctu/jwc/context/:type/:id" :paramsDesc="['通知类型','文章id']"/>
|
||||
|
||||
## 四川农业大学
|
||||
|
||||
### 招生就业
|
||||
|
||||
<Route author="nczitzk" example="/sicau/zsjy/bkszs" path="/sicau/zsjy/:category?" :paramsDesc="['分类,见下表,默认为本科生招生']">
|
||||
|
||||
| 本科生招生 | 研究生招生 | 毕业生选录指南 |
|
||||
| ---------- | ---------- | -------------- |
|
||||
| bkszs | yjszs | bysxlzn |
|
||||
|
||||
</Route>
|
||||
|
||||
## 四川职业技术学院
|
||||
|
||||
### 学院公告
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/zsjy/:category?': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'sicau.edu.cn': {
|
||||
_name: '',
|
||||
dky: [
|
||||
{
|
||||
title: '招生就业',
|
||||
docs: 'https://docs.rsshub.app/university.html#si-chuan-nong-ye-da-xue-zhao-sheng-jiu-ye',
|
||||
source: ['/'],
|
||||
target: '/sicau/zsjy/:category?',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/zsjy/:category?', require('./zsjy'));
|
||||
};
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 'bkszs';
|
||||
|
||||
const rootUrl = 'https://dky.sicau.edu.cn';
|
||||
const currentUrl = `${rootUrl}/zsjy/${category}.htm`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('a.tit')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
pubDate: parseDate(item.prev().text()),
|
||||
link: `${rootUrl}${item.attr('href').replace(/\.\./, '/')}`,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
content('.v_news_content p').slice(0, 2).remove();
|
||||
|
||||
item.description = content('.v_news_content').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue