feat(route): 西南交通大学教务网、扬华素质网 (#12101)
* feat(route): 西南交通大学教务网、扬华素质网 * fix(route): fix wrong radar rule * docs: fix format * fix(route): format code style
This commit is contained in:
@@ -3045,6 +3045,23 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
|
||||
|
||||
## 西南交通大学
|
||||
|
||||
### 教务网
|
||||
|
||||
<Route author="mobyw" example="/swjtu/jwc" path="/swjtu/jwc"/>
|
||||
|
||||
|
||||
### 扬华素质网
|
||||
|
||||
<Route author="mobyw" example="/swjtu/xg/tzgg" path="/swjtu/xg/:code?" :paramsDesc="['栏目(默认为tzgg)']">
|
||||
|
||||
栏目列表:
|
||||
|
||||
| 通知公告 | 扬华新闻 | 多彩学院 | 学工之家 |
|
||||
| ---- | ---- | ---- | ---- |
|
||||
| tzgg | yhxw | dcxy | xgzj |
|
||||
|
||||
</Route>
|
||||
|
||||
### 就业招聘信息
|
||||
|
||||
<Route author="qizidog" example="/swjtu/jyzpxx" path="/swjtu/jyzpxx"/>
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const rootURL = 'http://jwc.swjtu.edu.cn';
|
||||
const pageURL = `${rootURL}/vatuu/WebAction?setAction=newsList`;
|
||||
|
||||
const getItem = (item, cache) => {
|
||||
const newsInfo = item.find('h3').find('a');
|
||||
const newsTime = item.find('p').find('span').text().slice(0, 19);
|
||||
const newsTitle = newsInfo.text();
|
||||
const link = `${rootURL}${newsInfo.attr('href').slice(2)}`;
|
||||
return cache.tryGet(link, async () => {
|
||||
try {
|
||||
const resp = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
});
|
||||
const $$ = cheerio.load(resp.data);
|
||||
let newsText = $$('.content-main').html();
|
||||
if (!newsText) {
|
||||
newsText = '转发通知';
|
||||
}
|
||||
return {
|
||||
title: newsTitle,
|
||||
pubDate: parseDate(String(newsTime)),
|
||||
link,
|
||||
description: newsText,
|
||||
};
|
||||
} catch (error) {
|
||||
if (error.response && error.response.status === 404) {
|
||||
return {
|
||||
title: newsTitle,
|
||||
pubDate: parseDate(String(newsTime)),
|
||||
link,
|
||||
description: '',
|
||||
};
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const resp = await got({
|
||||
method: 'get',
|
||||
url: pageURL,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(resp.data);
|
||||
const list = $("[class='littleResultDiv']");
|
||||
|
||||
const items = await Promise.all(
|
||||
list.toArray().map((i) => {
|
||||
const item = $(i);
|
||||
return getItem(item, ctx.cache);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '西南交大-教务网通知',
|
||||
link: pageURL,
|
||||
item: items,
|
||||
allowEmpty: true,
|
||||
};
|
||||
};
|
||||
@@ -1,4 +1,6 @@
|
||||
module.exports = {
|
||||
'/jtys/yjs': ['qizidog'],
|
||||
'/jyzpxx': ['qizidog'],
|
||||
'/jwc': ['mobyw'],
|
||||
'/xg/:code?': ['mobyw'],
|
||||
};
|
||||
|
||||
@@ -17,5 +17,21 @@ module.exports = {
|
||||
target: '/swjtu/jyzpxx',
|
||||
},
|
||||
],
|
||||
jwc: [
|
||||
{
|
||||
title: '教务处通知',
|
||||
docs: 'https://docs.rsshub.app/university.html#xi-nan-jiao-tong-da-xue',
|
||||
source: ['/vatuu/WebAction', '/'],
|
||||
target: '/swjtu/jwc',
|
||||
},
|
||||
],
|
||||
xg: [
|
||||
{
|
||||
title: '扬华素质网',
|
||||
docs: 'https://docs.rsshub.app/university.html#xi-nan-jiao-tong-da-xue',
|
||||
source: ['/web/Home/PushNewsList', '/web/Home/NewsList', '/web/Home/ColourfulCollegeNewsList', '/web/Publicity/List', '/'],
|
||||
target: '/swjtu/xg',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/jtys/yjs', require('./jtys/yjs'));
|
||||
router.get('/jyzpxx', require('./jyzpxx'));
|
||||
router.get('/jwc', require('./jwc'));
|
||||
router.get('/xg/:code?', require('./xg'));
|
||||
};
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const rootURL = 'http://xg.swjtu.edu.cn';
|
||||
const listURL = {
|
||||
tzgg: `${rootURL}/web/Home/PushNewsList?Lmk7LJw34Jmu=010j.shtml`,
|
||||
yhxw: `${rootURL}/web/Home/NewsList?LJw34Jmu=011e.shtml`,
|
||||
dcxy: `${rootURL}/web/Home/ColourfulCollegeNewsList`,
|
||||
xgzj: `${rootURL}/web/Home/NewsList?xvw34vmu=010e.shtml`,
|
||||
};
|
||||
|
||||
const getItem = (item, cache) => {
|
||||
const newsInfo = item.find('h4').find('a');
|
||||
const newsTime = item.find('span.ctxlist-time').text();
|
||||
const newsTitle = newsInfo.text();
|
||||
const link = `${rootURL}${newsInfo.attr('href')}`;
|
||||
return cache.tryGet(link, async () => {
|
||||
try {
|
||||
const resp = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
});
|
||||
const $$ = cheerio.load(resp.data);
|
||||
let newsText = $$('.detail-content-text').html();
|
||||
if (!newsText) {
|
||||
newsText = '转发通知';
|
||||
}
|
||||
return {
|
||||
title: newsTitle,
|
||||
pubDate: parseDate(String(newsTime)),
|
||||
link,
|
||||
description: newsText,
|
||||
};
|
||||
} catch (error) {
|
||||
if (error.response && error.response.status === 404) {
|
||||
return {
|
||||
title: newsTitle,
|
||||
pubDate: parseDate(String(newsTime)),
|
||||
link,
|
||||
description: '',
|
||||
};
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const code = ctx.params.code ?? 'tzgg';
|
||||
const pageURL = listURL[code];
|
||||
|
||||
if (!pageURL) {
|
||||
throw new Error('code not supported');
|
||||
}
|
||||
|
||||
const resp = await got({
|
||||
method: 'get',
|
||||
url: pageURL,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(resp.data);
|
||||
const list = $('div.right-side ul.block-ctxlist li');
|
||||
|
||||
const items = await Promise.all(
|
||||
list.toArray().map((i) => {
|
||||
const item = $(i);
|
||||
return getItem(item, ctx.cache);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '西南交大-扬华素质网',
|
||||
link: pageURL,
|
||||
item: items,
|
||||
allowEmpty: true,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user