feat(route): add 山东科技大学研究生招生网 (#12411)
This commit is contained in:
@@ -2410,6 +2410,24 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
|
||||
|
||||
</Route>
|
||||
|
||||
## 山东科技大学
|
||||
|
||||
### 研究生招生网
|
||||
|
||||
<Route author="nczitzk" example="/sdust/yjsy/zhaosheng" path="/sdust/yjsy/zhaosheng/:id?" :paramsDesc="['栏目 id,见下表,默认为通知公告']">
|
||||
|
||||
栏目
|
||||
|
||||
| 招生简章 | 专业目录 | 往届录取 | 管理规定 | 资料下载 |
|
||||
| -------- | -------- | -------- | -------- | -------- |
|
||||
| zsjz | zyml | wjlq | glgd | zlxz |
|
||||
|
||||
| 通知公告 | 博士招生 | 硕士招生 | 推免生招生 | 招生宣传 |
|
||||
| -------- | -------- | -------- | ---------- | -------- |
|
||||
| tzgg | bszs | sszs | tms | zsxc |
|
||||
|
||||
</Route>
|
||||
|
||||
## 上海大学
|
||||
|
||||
### 上海大学官网信息
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/yjsy/zhaosheng/:id?': ['nczitzk'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'sdust.edu.cn': {
|
||||
_name: '山东科技大学',
|
||||
'.': [
|
||||
{
|
||||
title: '研究生招生网',
|
||||
docs: 'https://docs.rsshub.app/university.html#shan-dong-ke-ji-da-xue-yan-jiu-sheng-zhao-sheng-wang',
|
||||
source: ['/zhaosheng', '/'],
|
||||
target: (params, url) => `/sdust/yjsy/zhaosheng/${new URL(url).href.match(/zhaosheng\/(.*)\.htm/)[1]}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/yjsy/zhaosheng/:id?', require('./yjsy/zhaosheng'));
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id ?? 'tzgg';
|
||||
|
||||
const rootUrl = 'https://yjsy.sdust.edu.cn';
|
||||
const currentUrl = `${rootUrl}/zhaosheng/${id}.htm`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
let items = $('.pageUl ul li a')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.attr('title'),
|
||||
link: new URL(item.attr('href'), currentUrl).href,
|
||||
pubDate: parseDate(item.find('span').text()),
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('.txt, .v_news_content').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user