diff --git a/docs/university.md b/docs/university.md
index c93e6e6a6..ebc79e1eb 100644
--- a/docs/university.md
+++ b/docs/university.md
@@ -1930,7 +1930,7 @@ type 列表:
## 中国地质大学 (武汉)
-### 今日文章-包含全校网站最新通知
+### 今日文章 - 包含全校网站最新通知
@@ -1950,9 +1950,9 @@ type 列表:
-| 所有 | 学院新闻 | 通知公告 | 党建工作 | 学术动态 | 本科生教育 | 研究生教育 | 教工之家 |
-| -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
-| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
+| 所有 | 学院新闻 | 通知公告 | 党建工作 | 学术动态 | 本科生教育 | 研究生教育 | 教工之家 |
+| ---- | -------- | -------- | -------- | -------- | ---------- | ---------- | -------- |
+| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
## 中国海洋大学
diff --git a/lib/routes/universities/cug/gcxy/index.js b/lib/routes/universities/cug/gcxy/index.js
index 49b2503a2..f61586fd5 100644
--- a/lib/routes/universities/cug/gcxy/index.js
+++ b/lib/routes/universities/cug/gcxy/index.js
@@ -7,36 +7,36 @@ module.exports = async (ctx) => {
const typeUrl = [
{
name: '所有',
- url: ''
+ url: '',
},
{
name: '学院新闻',
- url: '/index/xyxw.htm'
+ url: '/index/xyxw.htm',
},
{
name: '通知公告',
- url: '/index/tzgg.htm'
+ url: '/index/tzgg.htm',
},
{
name: '党建工作',
- url: '/index/djgz.htm'
+ url: '/index/djgz.htm',
},
{
name: '学术动态',
- url: '/index/xsdt.htm'
+ url: '/index/xsdt.htm',
},
{
name: '本科生教育',
- url: '/index/bksjy.htm'
+ url: '/index/bksjy.htm',
},
{
name: '研究生教育',
- url: '/index/yjsjy.htm'
+ url: '/index/yjsjy.htm',
},
{
name: '教工之家',
- url: '/index/jgzj.htm'
- }
+ url: '/index/jgzj.htm',
+ },
];
let type = ctx.params && ctx.params.type;
@@ -72,42 +72,43 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const items = $('div.right_list > ul > li');
return await Promise.all(
- items.map(async (index, item) => {
- item = $(item);
- const a = item.find('a');
- const link = host + a.attr('href').replace('..', '');
- // console.log(link);
- return {
- title: a.attr('title'),
- link: link,
- description: await got({
- method: 'get',
- url: link,
- headers: {
- Referer: host,
- },
- }).then((res) => {
- const $ = cheerio.load(res.data);
- return $('.v_news_content').html();
- }).catch(() => ''),
- pubDate: item.find('span').text(),
- };
- }).get()
+ items
+ .map(async (index, item) => {
+ item = $(item);
+ const a = item.find('a');
+ const link = host + a.attr('href').replace('..', '');
+ // console.log(link);
+ return {
+ title: a.attr('title'),
+ link: link,
+ description: await got({
+ method: 'get',
+ url: link,
+ headers: {
+ Referer: host,
+ },
+ })
+ .then((res) => {
+ const $ = cheerio.load(res.data);
+ return $('.v_news_content').html();
+ })
+ .catch(() => ''),
+ pubDate: item.find('span').text(),
+ };
+ })
+ .get()
);
} catch (e) {
return [];
}
};
- const outList = await Promise.all(
- typeList
- .map(async (t) => await getItems(typeUrl[t].url))
- );
+ const outList = await Promise.all(typeList.map(async (t) => await getItems(typeUrl[t].url)));
ctx.state.data = {
title: '[' + typeUrl[type].name + ']' + 'CUG-工程学院',
link: host + typeUrl[type].url,
description: '中国地质大学(武汉)工程学院-' + typeUrl[type].name,
- item: outList.reduce((p, n) => p.concat(n))
+ item: outList.reduce((p, n) => p.concat(n)),
};
};
diff --git a/lib/routes/universities/cug/news.js b/lib/routes/universities/cug/news.js
index 29023ef8d..f7411e9d5 100644
--- a/lib/routes/universities/cug/news.js
+++ b/lib/routes/universities/cug/news.js
@@ -2,63 +2,62 @@ const cheerio = require('cheerio');
const got = require('@/utils/got');
module.exports = async (ctx) => {
- // 发起 HTTP GET 请求
+ // 发起 HTTP GET 请求
- const host = 'http://xxhb.cug.edu.cn/zqxt/zqjsjg.jsp?wbtreeid=1283&selectType=1&searchScope=0';
+ const host = 'http://xxhb.cug.edu.cn/zqxt/zqjsjg.jsp?wbtreeid=1283&selectType=1&searchScope=0';
- const response = await got({
- method: 'get',
- url: host,
- });
+ const response = await got({
+ method: 'get',
+ url: host,
+ });
- const data = response.data;
+ const data = response.data;
- const $ = cheerio.load(data);
- const list = $('form[id=searchlistform1] > table.listFrame > tbody > tr > td');
- const results = [];
- let item = {};
- for (let i = 0; i < list.length; i++) {
- const d = $(list[i]);
- d.find('i').remove();
- const title = d.find('span.titlefontstyle206274');
- const from = d.find('span.sourcesitefontstyle206274');
- const description = d.find('span.contentfontstyle206274');
- const time = d.find('span.timefontstyle206274');
+ const $ = cheerio.load(data);
+ const list = $('form[id=searchlistform1] > table.listFrame > tbody > tr > td');
+ const results = [];
+ let item = {};
+ for (let i = 0; i < list.length; i++) {
+ const d = $(list[i]);
+ d.find('i').remove();
+ const title = d.find('span.titlefontstyle206274');
+ const from = d.find('span.sourcesitefontstyle206274');
+ const description = d.find('span.contentfontstyle206274');
+ const time = d.find('span.timefontstyle206274');
- if (title.length) {
- item.title = from.text() + title.text();
- item.link = d.find('a').attr('href');
- } else if (description.length) {
- item.description = item.description ? item.description + d.text() : d.text();
- } else if (time.length) {
- item.pubDate = new Date(time.text().replace('发表时间:', '').replace('年', '-').replace('月', '-').replace('日', '')).toUTCString();
- results.push(item);
- item = {};
- }
- }
-
- let out = await Promise.all(
- results
- .map(async (element) => {
- const link = element.link;
- try {
- const result = await got.get(link);
- const $ = cheerio.load(result.data);
- element.description = $('.v_news_content').html();
- element.enabled = true;
- } catch (e) {
- element.enabled = false;
+ if (title.length) {
+ item.title = from.text() + title.text();
+ item.link = d.find('a').attr('href');
+ } else if (description.length) {
+ item.description = item.description ? item.description + d.text() : d.text();
+ } else if (time.length) {
+ item.pubDate = new Date(time.text().replace('发表时间:', '').replace('年', '-').replace('月', '-').replace('日', '')).toUTCString();
+ results.push(item);
+ item = {};
}
- return Promise.resolve(element);
- })
- );
+ }
- out = out.filter((item) => item.enabled === true);
+ let out = await Promise.all(
+ results.map(async (element) => {
+ const link = element.link;
+ try {
+ const result = await got.get(link);
+ const $ = cheerio.load(result.data);
+ element.description = $('.v_news_content').html();
+ element.enabled = true;
+ } catch (e) {
+ element.enabled = false;
+ }
+ return Promise.resolve(element);
+ })
+ );
- ctx.state.data = {
- title: 'CUG-今日文章',
- link: host,
- description: '中国地质大学(武汉) 每日文章,几乎包含全校站点最新信息。',
- item: out,
- };
+ out = out.filter((item) => item.enabled === true);
+
+ ctx.state.data = {
+ title: 'CUG-今日文章',
+ link: host,
+ description: '中国地质大学(武汉) 每日文章,几乎包含全校站点最新信息。',
+ item: out,
+ };
};