feat: add 部分大学 (#4820)

This commit is contained in:
Diffumist
2020-05-22 00:21:44 +08:00
committed by GitHub
parent 0e9d21a7b8
commit d7b826168c
6 changed files with 281 additions and 0 deletions
+21
View File
@@ -24,6 +24,21 @@ pageClass: routes
<Route author="exuanbo" example="/polimi/news" path="/polimi/news/:language?" :paramsDesc="['English language code en']" />
## 安徽工业大学
### 教务处
<Route author="Diffumist" example="/ahut/jwc" path="/ahut/jwc" />
### 学校要闻
<Route author="Diffumist" example="/ahut/news" path="/ahut/news" />
### 计算机学院公告
<Route author="Diffumist" example="/ahut/cstzgg" path="/ahut/cstzgg" />
## 安徽农业大学
### 计算机学院
@@ -1231,6 +1246,12 @@ type 列表:
<Route author="HenryQW" example="/shanghaitech/sist/activity" path="/shanghaitech/sist/activity"/>
## 上海理工大学
### 教务处
<Route author="Diffumist" example="/usst/jwc" path="/usst/jwc"/>
## 上海立信会计金融学院
::: warning 注意
+8
View File
@@ -795,6 +795,14 @@ router.get('/ahau/main/:type', require('./routes/universities/ahau/main/index'))
// 安徽医科大学研究生学院
router.get('/ahmu/news', require('./routes/universities/ahmu/news'));
// 安徽工业大学
router.get('/ahut/news', require('./routes/universities/ahut/news'));
router.get('/ahut/jwc', require('./routes/universities/ahut/jwc'));
router.get('/ahut/cstzgg', require('./routes/universities/ahut/cstzgg'));
// 上海理工大学
router.get('/usst/jwc', require('./routes/universities/usst/jwc'));
// ifanr
router.get('/ifanr/:channel?', require('./routes/ifanr/index'));
+64
View File
@@ -0,0 +1,64 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const url = `http://jsjxy.ahut.edu.cn/list.jsp?urltype=tree.TreeTempUrl&wbtreeid=1887`;
const response = await got({
method: 'get',
url: url,
});
const $ = cheerio.load(response.data);
$('.clickstyle1022').remove();
$('td[width = "1%"]').remove();
$('tr[height = "1"]').remove();
$('td[colspan="3"]').remove();
$('.leaderfont47822').remove();
// ## 获取列表
const list = $('.winstyle47822 > tbody > tr').get();
// ## 定义输出的item
const out = await Promise.all(
// ### 遍历列表,筛选出自己想要的内容
list.map(async (item) => {
const itemSingle = cheerio.load(item);
const title = itemSingle.text().replace(/^[\s]+|[\s]+$/g, '');
const re = /<a[^>]*href=['"]([^"]*)['"][^>]*>/g;
let singleUrl = '';
if (re.exec(itemSingle.html()) !== null) {
singleUrl = RegExp.$1;
}
if (singleUrl.search('http') === -1) {
singleUrl = 'http://jsjxy.ahut.edu.cn' + singleUrl;
}
const cache = await ctx.cache.get(singleUrl); // ### 得到全局中的缓存信息
// ### 判断缓存是否存在,如果存在即跳过此次获取的信息
if (cache) {
return Promise.resolve(JSON.parse(cache));
}
// 获取详情页面的介绍
const detail_response = await got({
method: 'get',
url: singleUrl,
});
const $ = cheerio.load(detail_response.data);
const detail_content = $('.contentstyle47853 > div').html();
// ### 设置 RSS feed item
const single = {
title: title.replace(/(^\s*)|(\s*$)/g, ''),
link: singleUrl,
// author: author,
description: detail_content,
// pubDate: updateDate,
};
// // ### 设置缓存
ctx.cache.set(singleUrl, JSON.stringify(single));
return Promise.resolve(single);
// }
})
);
ctx.state.data = {
title: `安徽工业大学 - 计算机学院公告`,
link: 'http://jsjxy.ahut.edu.cn/list.jsp?urltype=tree.TreeTempUrl&wbtreeid=1887',
description: `安徽工业大学 - 计算机学院公告`,
item: out,
};
};
+62
View File
@@ -0,0 +1,62 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const url = `http://jwc.ahut.edu.cn/list.jsp?urltype=tree.TreeTempUrl&wbtreeid=1082`;
const response = await got({
method: 'get',
url: url,
});
const $ = cheerio.load(response.data);
$('tr[height="1"]').remove();
$('td[width="1%"]').remove();
$('td[colspan="3"]').remove();
// ## 获取列表
const list = $('.winstyle44456 > tbody > tr >td').get();
// ## 定义输出的item
const out = await Promise.all(
// ### 遍历列表,筛选出自己想要的内容
list.map(async (item) => {
const itemSingle = cheerio.load(item);
const title = itemSingle.text();
const re = /<a[^>]*href=['"]([^"]*)['"][^>]*>/g;
let singleUrl = '';
if (re.exec(itemSingle.html()) !== null) {
singleUrl = RegExp.$1;
}
if (singleUrl.search('http') === -1) {
singleUrl = 'http://jwc.ahut.edu.cn' + singleUrl;
}
const cache = await ctx.cache.get(singleUrl); // ### 得到全局中的缓存信息
// ### 判断缓存是否存在,如果存在即跳过此次获取的信息
if (cache) {
return Promise.resolve(JSON.parse(cache));
}
// 获取详情页面的介绍
const detail_response = await got({
method: 'get',
url: singleUrl,
});
const $ = cheerio.load(detail_response.data);
const detail_content = $('.winstyle44457 > tbody').html();
// ### 设置 RSS feed item
const single = {
title: title,
link: singleUrl,
// author: author,
description: detail_content,
// pubDate: updateDate,
};
// // ### 设置缓存
ctx.cache.set(singleUrl, JSON.stringify(single));
return Promise.resolve(single);
// }
})
);
ctx.state.data = {
title: `安徽工业大学 - 教务处`,
link: 'http://jwc.ahut.edu.cn/list.jsp?urltype=tree.TreeTempUrl&wbtreeid=1082',
description: `安徽工业大学 - 教务处`,
item: out,
};
};
+64
View File
@@ -0,0 +1,64 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const url = `http://news.ahut.edu.cn/list.jsp?urltype=tree.TreeTempUrl&wbtreeid=1002`;
const response = await got({
method: 'get',
url: url,
});
const $ = cheerio.load(response.data);
$('tr[height="26"]').slice(20);
$('td[width="1%"]').remove();
$('.clickstyle1022').remove();
$('td[colspan="3"]').remove();
$('.leaderfont1022').remove();
// ## 获取列表
const list = $('.winstyle1022 > tbody > tr > td').get();
// ## 定义输出的item
const out = await Promise.all(
// ### 遍历列表,筛选出自己想要的内容
list.map(async (item) => {
const itemSingle = cheerio.load(item);
const title = itemSingle.text().trim();
const re = /<a[^>]*href=['"]([^"]*)['"][^>]*>/g;
let singleUrl = '';
if (re.exec(itemSingle.html()) !== null) {
singleUrl = RegExp.$1;
}
if (singleUrl.search('http') === -1) {
singleUrl = 'http://news.ahut.edu.cn' + singleUrl;
}
const cache = await ctx.cache.get(singleUrl); // ### 得到全局中的缓存信息
// ### 判断缓存是否存在,如果存在即跳过此次获取的信息
if (cache) {
return Promise.resolve(JSON.parse(cache));
}
// 获取详情页面的介绍
const detail_response = await got({
method: 'get',
url: singleUrl,
});
const $ = cheerio.load(detail_response.data);
const detail_content = $('.winstyle1023').html();
// ### 设置 RSS feed item
const single = {
title: title,
link: singleUrl,
// author: author,
description: detail_content,
// pubDate: updateDate,
};
// // ### 设置缓存
ctx.cache.set(singleUrl, JSON.stringify(single));
return Promise.resolve(single);
// }
})
);
ctx.state.data = {
title: `安徽工业大学 - 学校要闻`,
link: 'http://news.ahut.edu.cn/list.jsp?urltype=tree.TreeTempUrl&wbtreeid=1002',
description: `安徽工业大学 - 学校要闻`,
item: out,
};
};
+62
View File
@@ -0,0 +1,62 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const url = `http://jwc.usst.edu.cn`;
const response = await got({
method: 'get',
url: url,
});
const $ = cheerio.load(response.data);
$('td[width="30px"]').remove();
$('td[width="195"]').remove();
// ## 获取列表
const list = $('.main_shadow > table > tbody > tr > td').get();
// ## 定义输出的item
const out = await Promise.all(
// ### 遍历列表,筛选出自己想要的内容
list.map(async (item) => {
const itemSingle = cheerio.load(item);
const title = itemSingle.text();
const re = /<a[^>]*href=['"]([^"]*)['"][^>]*>(.*?)<\/a>/g;
let singleUrl = '';
if (re.exec(itemSingle.html()) !== null) {
singleUrl = RegExp.$1;
}
if (singleUrl.search('http') === -1) {
singleUrl = `http://jwc.usst.edu.cn/` + singleUrl;
}
const cache = await ctx.cache.get(singleUrl); // ### 得到全局中的缓存信息
// ### 判断缓存是否存在,如果存在即跳过此次获取的信息
if (cache) {
return Promise.resolve(JSON.parse(cache));
}
// 获取详情页面的介绍
const detail_response = await got({
method: 'get',
url: singleUrl,
});
const $ = cheerio.load(detail_response.data);
const detail_content = $('.wp_articlecontent > .Article_Content').html();
// ### 设置 RSS feed item
const single = {
title: title,
link: singleUrl,
// author: author,
description: detail_content,
// pubDate: updateDate,
};
// // ### 设置缓存
ctx.cache.set(singleUrl, JSON.stringify(single));
return Promise.resolve(single);
// }
})
);
ctx.state.data = {
title: `上海理工大学 - 教务处`,
link: 'http://jwc.usst.edu.cn/',
description: `上海理工大学 - 教务处`,
item: out,
};
};