mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-19 06:38:55 +08:00
哈工程添加分类和文章内容 (#649)
This commit is contained in:
@@ -1980,11 +1980,64 @@ GitHub 官方也提供了一些 RSS:
|
|||||||
|
|
||||||
#### 本科生院工作通知 <Author uid="XYenon"/>
|
#### 本科生院工作通知 <Author uid="XYenon"/>
|
||||||
|
|
||||||
举例: <https://rsshub.app/heu/ugs/news>
|
举例: <https://rsshub.app/heu/ugs/news/jwc/jxap>
|
||||||
|
|
||||||
路由: `/heu/ugs/news`
|
路由: `/heu/ugs/news/:author?/:category?`
|
||||||
|
|
||||||
参数: 无
|
参数:
|
||||||
|
|
||||||
|
- author,可选,发布部门,默认为 `gztz`
|
||||||
|
- category,可选,分类,默认为 `all`
|
||||||
|
|
||||||
|
author 列表:
|
||||||
|
|
||||||
|
| 教务处 | 实践教学与交流处 | 教育评估处 | 专业建设处 | 国家大学生文化素质基地 | 教师教学发展中心 | 综合办公室 | 工作通知 |
|
||||||
|
| ------ | ---------------- | ---------- | ---------- | ---------------------- | ---------------- | ---------- | -------- |
|
||||||
|
| jwc | sjjxyjlzx | jypgc | zyjsc | gjdxswhszjd | jsjxfzzx | zhbgs | gztz |
|
||||||
|
|
||||||
|
category 列表:
|
||||||
|
|
||||||
|
`all` 为全部
|
||||||
|
|
||||||
|
教务处:
|
||||||
|
|
||||||
|
| 教学安排 | 考试管理 | 学籍管理 | 外语统考 | 成绩管理 |
|
||||||
|
| -------- | -------- | -------- | -------- | -------- |
|
||||||
|
| jxap | ksgl | xjgl | wytk | cjgl |
|
||||||
|
|
||||||
|
实践教学与交流处:
|
||||||
|
|
||||||
|
| 实验教学 | 实验室建设 | 校外实习 | 学位论文 | 课程设计 | 创新创业 | 校际交流 |
|
||||||
|
| -------- | ---------- | -------- | -------- | -------- | -------- | -------- |
|
||||||
|
| syjx | sysjs | xwsx | xwlw | kcsj | cxcy | xjjl |
|
||||||
|
|
||||||
|
教育评估处:
|
||||||
|
|
||||||
|
| 教学研究与教学成果 | 质量监控 |
|
||||||
|
| ------------------ | -------- |
|
||||||
|
| jxyjyjxcg | zljk |
|
||||||
|
|
||||||
|
专业建设处:
|
||||||
|
|
||||||
|
| 专业与教材建设 | 陈赓实验班 | 教学名师与优秀主讲教师 | 课程建设 | 双语教学 |
|
||||||
|
| -------------- | ---------- | ---------------------- | -------- | -------- |
|
||||||
|
| zyyjcjs | cgsyb | jxmsyyxzjjs | kcjs | syjx |
|
||||||
|
|
||||||
|
国家大学生文化素质基地:无
|
||||||
|
|
||||||
|
教师教学发展中心:
|
||||||
|
|
||||||
|
| 教师培训 |
|
||||||
|
| -------- |
|
||||||
|
| jspx |
|
||||||
|
|
||||||
|
综合办公室:
|
||||||
|
|
||||||
|
| 联系课程 |
|
||||||
|
| -------- |
|
||||||
|
| lxkc |
|
||||||
|
|
||||||
|
工作通知:无
|
||||||
|
|
||||||
## 传统媒体
|
## 传统媒体
|
||||||
|
|
||||||
|
|||||||
@@ -503,7 +503,7 @@ router.get('/cas/sim/academic', require('./routes/universities/cas/sim/academic'
|
|||||||
router.get('/njupt/jwc/:type?', require('./routes/universities/njupt/jwc'));
|
router.get('/njupt/jwc/:type?', require('./routes/universities/njupt/jwc'));
|
||||||
|
|
||||||
// 哈尔滨工程大学
|
// 哈尔滨工程大学
|
||||||
router.get('/heu/ugs/news', require('./routes/universities/heu/ugs/news'));
|
router.get('/heu/ugs/news/:author?/:category?', require('./routes/universities/heu/ugs/news'));
|
||||||
|
|
||||||
// ifanr
|
// ifanr
|
||||||
router.get('/ifanr/appso', require('./routes/ifanr/appso'));
|
router.get('/ifanr/appso', require('./routes/ifanr/appso'));
|
||||||
|
|||||||
@@ -1,34 +1,122 @@
|
|||||||
const axios = require('../../../../utils/axios');
|
const axios = require('../../../../utils/axios');
|
||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
|
const url = require('url');
|
||||||
|
|
||||||
|
const baseUrl = 'http://ugs.hrbeu.edu.cn';
|
||||||
|
|
||||||
|
const authorMap = {
|
||||||
|
gztz: {
|
||||||
|
all: '/2821',
|
||||||
|
},
|
||||||
|
jwc: {
|
||||||
|
all: '/jwc',
|
||||||
|
jxap: '/2847',
|
||||||
|
ksgl: '/2895',
|
||||||
|
xjgl: '/2902',
|
||||||
|
wytk: '/2897',
|
||||||
|
cjgl: '/2901',
|
||||||
|
},
|
||||||
|
sjjxyjlc: {
|
||||||
|
all: '/3206',
|
||||||
|
syjx: '/2847',
|
||||||
|
sysjs: '/sysjs',
|
||||||
|
xwsx: '/2909',
|
||||||
|
xwlw: '/2910',
|
||||||
|
kcsj: '/2911',
|
||||||
|
cxcy: '/2913',
|
||||||
|
xjjl: '/xjjl',
|
||||||
|
},
|
||||||
|
jypgc: {
|
||||||
|
all: '/3207',
|
||||||
|
jxyjyjxcg: '/2916',
|
||||||
|
zljk: '/2917',
|
||||||
|
},
|
||||||
|
zyjsc: {
|
||||||
|
all: '/3208',
|
||||||
|
zyyjcjs: '/2914',
|
||||||
|
cgsyb: '/2925',
|
||||||
|
jxmsyyxzjjs: '/2918',
|
||||||
|
ktjs: '/2919',
|
||||||
|
syjx: '/2920',
|
||||||
|
},
|
||||||
|
gjdxswhszjd: {
|
||||||
|
all: '/3209',
|
||||||
|
},
|
||||||
|
jsjxfzzx: {
|
||||||
|
all: '/3210',
|
||||||
|
jspx: '/2915',
|
||||||
|
},
|
||||||
|
zhbgs: {
|
||||||
|
all: '/3211',
|
||||||
|
lxkc: '/lxkc',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
|
const author = ctx.params.author || 'gztz';
|
||||||
|
const category = ctx.params.category || 'all';
|
||||||
|
const link = baseUrl + authorMap[author][category] + '/list.htm';
|
||||||
const response = await axios({
|
const response = await axios({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: 'http://ugs.hrbeu.edu.cn/2821/list.htm',
|
url: link,
|
||||||
headers: {
|
headers: {
|
||||||
Referer: 'http://ugs.hrbeu.edu.cn',
|
Referer: baseUrl,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
const data = response.data;
|
const urlList = $('.wp_article_list_table .border9')
|
||||||
|
.slice(0, 10)
|
||||||
|
.map((i, e) => $('a', e).attr('href'))
|
||||||
|
.get();
|
||||||
|
|
||||||
const $ = cheerio.load(data);
|
const titleList = $('.wp_article_list_table .border9')
|
||||||
const list = $('.wp_article_list_table .border9');
|
.slice(0, 10)
|
||||||
|
.map((i, e) => $('a', e).text())
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const dateList = $('.wp_article_list_table .border9')
|
||||||
|
.slice(0, 10)
|
||||||
|
.map((i, e) => $('.date', e).text())
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const out = await Promise.all(
|
||||||
|
urlList.map(async (itemUrl, index) => {
|
||||||
|
itemUrl = url.resolve(baseUrl, itemUrl);
|
||||||
|
if (itemUrl.indexOf('.htm') !== -1) {
|
||||||
|
const cache = await ctx.cache.get(itemUrl);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
const response = await axios.get(itemUrl);
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
const single = {
|
||||||
|
title: titleList[index],
|
||||||
|
link: itemUrl,
|
||||||
|
description: $('.wp_articlecontent')
|
||||||
|
.html()
|
||||||
|
.replace(/src="\//g, `src="${url.resolve(baseUrl, '.')}`)
|
||||||
|
.replace(/href="\//g, `href="${url.resolve(baseUrl, '.')}`)
|
||||||
|
.trim(),
|
||||||
|
pubDate: dateList[index],
|
||||||
|
};
|
||||||
|
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||||
|
return Promise.resolve(single);
|
||||||
|
} else {
|
||||||
|
const single = {
|
||||||
|
title: titleList[index],
|
||||||
|
link: itemUrl,
|
||||||
|
description: '此链接为文件,请点击下载',
|
||||||
|
pubDate: dateList[index],
|
||||||
|
};
|
||||||
|
return Promise.resolve(single);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
title: '哈尔滨工程大学本科生院工作通知',
|
title: '哈尔滨工程大学本科生院工作通知',
|
||||||
link: 'http://ugs.hrbeu.edu.cn/2821/list.htm',
|
link: baseUrl,
|
||||||
item:
|
item: out,
|
||||||
list &&
|
|
||||||
list
|
|
||||||
.map((index, item) => {
|
|
||||||
item = $(item);
|
|
||||||
return {
|
|
||||||
title: item.find('a').text(),
|
|
||||||
pubDate: new Date(item.find('.date').text()).toUTCString(),
|
|
||||||
link: `http://ugs.hrbeu.edu.cn${item.find('a').attr('href')}`,
|
|
||||||
};
|
|
||||||
})
|
|
||||||
.get(),
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user