feat(route): add 四川工商学院公告 (#12499)
* feat(route): add 四川工商学院公告 * Update lib/v2/stbu/xyxw.js * fix(route): adjusted timezone to UTC+8 ---------
This commit is contained in:
parent
6742ef803a
commit
6d78f48576
|
|
@ -2666,6 +2666,20 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
|
|||
|
||||
<Route author="stevelee477" example="/scu/xg/notice" path="/scu/xg/notice" />
|
||||
|
||||
## 四川工商学院
|
||||
|
||||
### 学院新闻
|
||||
|
||||
<Route author="HyperCherry" example="/stbu/xyxw" path="/stbu/syxw" />
|
||||
|
||||
### 计算机学院通知公告
|
||||
|
||||
<Route author="HyperCherry" example="/stbu/jsjxy" path="/stbu/jsjxy" />
|
||||
|
||||
::: warning 注意
|
||||
计算机学院通知公告疑似禁止了非大陆IP访问,使用路由需要自行 [部署](https://docs.rsshub.app/install)。
|
||||
:::
|
||||
|
||||
## 四川旅游学院
|
||||
|
||||
### 信息与工程学院动态公告列表
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const iconv = require('iconv-lite');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
const gbk2utf8 = (s) => iconv.decode(s, 'gbk');
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://jsjxy.stbu.edu.cn/news/';
|
||||
const { data: response } = await got(baseUrl, {
|
||||
responseType: 'buffer',
|
||||
https: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(gbk2utf8(response));
|
||||
const list = $('.content dl h4')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a').first();
|
||||
return {
|
||||
title: a.text(),
|
||||
link: a.attr('href'),
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link, {
|
||||
responseType: 'buffer',
|
||||
https: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(gbk2utf8(response));
|
||||
item.description = $('.content14').first().html().trim();
|
||||
item.pubDate = timezone(parseDate($('.article .source').text().split('日期:')[1].replace('\n', '').trim()), +8);
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '四川工商学院计算机学院 - 新闻动态',
|
||||
link: baseUrl,
|
||||
description: '四川工商学院计算机学院 - 新闻动态',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
'/jsjxy': ['HyperCherry'],
|
||||
'/xyxw': ['HyperCherry'],
|
||||
};
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
module.exports = {
|
||||
'stbu.edu.cn': {
|
||||
_name: '四川工商学院',
|
||||
'.': [
|
||||
{
|
||||
title: '学院新闻',
|
||||
docs: 'https://docs.rsshub.app/university.html#si-chuan-gong-shang-xue-yuan',
|
||||
source: ['/html/news/xueyuan', '/'],
|
||||
target: '/stbu/xyxw',
|
||||
},
|
||||
],
|
||||
jsjxy: [
|
||||
{
|
||||
title: '计算机学院通知公告',
|
||||
docs: 'https://docs.rsshub.app/university.html#si-chuan-gong-shang-xue-yuan',
|
||||
source: ['/news', '/'],
|
||||
target: '/stbu/jsjxy',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/jsjxy', require('./jsjxy'));
|
||||
router.get('/xyxw', require('./xyxw'));
|
||||
};
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const iconv = require('iconv-lite');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
const gbk2utf8 = (s) => iconv.decode(s, 'gbk');
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://www.stbu.edu.cn';
|
||||
const requestUrl = `${baseUrl}/html/news/xueyuan/`;
|
||||
const { data: response } = await got(requestUrl, {
|
||||
responseType: 'buffer',
|
||||
https: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(gbk2utf8(response));
|
||||
const list = $('.style_2 .Simple_title')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a').first();
|
||||
return {
|
||||
title: a.text(),
|
||||
link: `${baseUrl}${a.attr('href')}`,
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link, {
|
||||
responseType: 'buffer',
|
||||
https: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(gbk2utf8(response));
|
||||
item.description = $('.artmainl .articlemain').first().html();
|
||||
item.pubDate = timezone(parseDate($('.artmainl .info').text().split('|')[2].split(':')[1].trim()), +8);
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '四川工商学院 - 学院新闻',
|
||||
link: requestUrl,
|
||||
description: '四川工商学院 - 学院新闻',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue