diff --git a/docs/university.md b/docs/university.md index 361264423..ddc9c9214 100644 --- a/docs/university.md +++ b/docs/university.md @@ -482,6 +482,12 @@ xskb1 对应 +## 广州大学 + +## 广州大学研招网通知公告 + + + ## 广州航海学院 ## 广州航海学院教务处通知公告 @@ -492,12 +498,6 @@ xskb1 对应 -## 广州大学 - -## 广州大学研招网通知公告 - - - ## 桂林电子科技大学 ### 新闻资讯 diff --git a/lib/routes/universities/gzmtu/jwc/index.js b/lib/routes/universities/gzmtu/jwc/index.js index ac6252ea2..3be68ad30 100644 --- a/lib/routes/universities/gzmtu/jwc/index.js +++ b/lib/routes/universities/gzmtu/jwc/index.js @@ -3,12 +3,12 @@ const cheerio = require('cheerio'); const utils = require('./utils'); module.exports = async (ctx) => { - const link = 'http://jwc.gzmtu.edu.cn/';// 教务处URL - const response = await got.get(link);// 获取HTML + const link = 'http://jwc.gzmtu.edu.cn/'; // 教务处URL + const response = await got.get(link); // 获取HTML const data = response.data; // 请求返回的HTML - const $ = cheerio.load(data);// cheerio加载数据 - const list = $('div .center_article_list').find('td').get();// 筛选出每则通知作为列表索引 - const result = await utils.ProcessFeed(list, ctx.cache, link);// 加载每则通知详情内容 + const $ = cheerio.load(data); // cheerio加载数据 + const list = $('div .center_article_list').find('td').get(); // 筛选出每则通知作为列表索引 + const result = await utils.ProcessFeed(list, ctx.cache, link); // 加载每则通知详情内容 ctx.state.data = { title: '广州航海学院教务处通知公告', // RSS名称 @@ -18,4 +18,4 @@ module.exports = async (ctx) => { allowEmpty: false, // 是否允许RSS内容为空 language: 'zh-cn', // 频道语言 }; -}; \ No newline at end of file +}; diff --git a/lib/routes/universities/gzmtu/jwc/utils.js b/lib/routes/universities/gzmtu/jwc/utils.js index 61fe07d60..d7525154f 100644 --- a/lib/routes/universities/gzmtu/jwc/utils.js +++ b/lib/routes/universities/gzmtu/jwc/utils.js @@ -5,7 +5,8 @@ const url = require('url'); const ProcessFeed = async (list, cache, link) => await Promise.all( list - .filter(function (item) {// 查询是否具有文章链接,没有则跳过 + .filter(function (item) { + // 查询是否具有文章链接,没有则跳过 const $ = cheerio.load(item); if ($('a').length > 0) { return true; @@ -14,18 +15,17 @@ const ProcessFeed = async (list, cache, link) => }) .map(async (item) => { let $ = cheerio.load(item); - const $url = url.resolve(link, $('a').attr('href'));// 原文链接 + const $url = url.resolve(link, $('a').attr('href')); // 原文链接 const key = $url; // 查询是否有未过期缓存 const value = await cache.get(key); if (value) { // 查询返回未过期缓存 return JSON.parse(value); - } - else { - const response = await got.get($url);// 获取HTML - const data = response.data;// 请求返回的HTML - $ = cheerio.load(data);// cheerio加载数据 + } else { + const response = await got.get($url); // 获取HTML + const data = response.data; // 请求返回的HTML + $ = cheerio.load(data); // cheerio加载数据 // 去除样式 $('img, div, span, p, table, td, tr').removeAttr('style'); diff --git a/lib/routes/universities/gzmtu/tsg/index.js b/lib/routes/universities/gzmtu/tsg/index.js index 0f9e430ea..6c7011862 100644 --- a/lib/routes/universities/gzmtu/tsg/index.js +++ b/lib/routes/universities/gzmtu/tsg/index.js @@ -3,12 +3,12 @@ const cheerio = require('cheerio'); const utils = require('./utils'); module.exports = async (ctx) => { - const link = 'http://tsg.gzmtu.edu.cn/';// 图书馆URL - const response = await got.get(link);// 获取HTML + const link = 'http://tsg.gzmtu.edu.cn/'; // 图书馆URL + const response = await got.get(link); // 获取HTML const data = response.data; // 请求返回的HTML - const $ = cheerio.load(data);// cheerio加载数据 - const list = $('ul .picture_ul').find('li').get();// 筛选出每则通知作为列表索引 - const result = await utils.ProcessFeed(list, ctx.cache, link);// 加载每则通知详情内容 + const $ = cheerio.load(data); // cheerio加载数据 + const list = $('ul .picture_ul').find('li').get(); // 筛选出每则通知作为列表索引 + const result = await utils.ProcessFeed(list, ctx.cache, link); // 加载每则通知详情内容 ctx.state.data = { title: '广州航海学院图书馆通知公告', // RSS名称 @@ -18,4 +18,4 @@ module.exports = async (ctx) => { allowEmpty: false, // 是否允许RSS内容为空 language: 'zh-cn', // 频道语言 }; -}; \ No newline at end of file +}; diff --git a/lib/routes/universities/gzmtu/tsg/utils.js b/lib/routes/universities/gzmtu/tsg/utils.js index 163ff166c..fd9dc8e15 100644 --- a/lib/routes/universities/gzmtu/tsg/utils.js +++ b/lib/routes/universities/gzmtu/tsg/utils.js @@ -5,7 +5,8 @@ const url = require('url'); const ProcessFeed = async (list, cache, link) => await Promise.all( list - .filter(function (item) {// 查询是否具有文章链接,没有则跳过 + .filter(function (item) { + // 查询是否具有文章链接,没有则跳过 const $ = cheerio.load(item); if ($('a').length > 0) { return true; @@ -14,18 +15,17 @@ const ProcessFeed = async (list, cache, link) => }) .map(async (item) => { let $ = cheerio.load(item); - const $url = url.resolve(link, $('a').attr('href'));// 原文链接 + const $url = url.resolve(link, $('a').attr('href')); // 原文链接 const key = $url; // 查询是否有未过期缓存 const value = await cache.get(key); if (value) { // 查询返回未过期缓存 return JSON.parse(value); - } - else { - const response = await got.get($url);// 获取HTML - const data = response.data;// 请求返回的HTML - $ = cheerio.load(data);// cheerio加载数据 + } else { + const response = await got.get($url); // 获取HTML + const data = response.data; // 请求返回的HTML + $ = cheerio.load(data); // cheerio加载数据 // 去除样式 $('img, div, span, p, table, td, tr').removeAttr('style');