fix(route): 南京航空航天大学路由缓存 (#10656)

* feat(route): fix 南京航空航天大学路由缓存

* fix(route): sort the routes
This commit is contained in:
Cyrus 2022-08-30 19:52:42 +08:00 committed by GitHub
parent e6341a512c
commit 3a65aec136
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 68 additions and 95 deletions

View File

@ -1811,7 +1811,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
### 教务处
<Route author="arcosx Seiry qrzbing Xm798" example="/nuaa/jwc/tzgg" path="/nuaa/jwc/:type/:getDescription?" :paramsDesc="['分类名', '是否获取全文']" puppeteer="1">
<Route author="arcosx Seiry qrzbing Xm798" example="/nuaa/jwc/tzgg/getDescription" path="/nuaa/jwc/:type/:getDescription?" :paramsDesc="['分类名,见下表', '是否获取全文']" puppeteer="1" radar="1">
| 通知公告 | 教学服务 | 教学建设 | 学生培养 | 教学资源 |
| ---- | ---- | ---- | ---- | ---- |
@ -1821,7 +1821,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
### 研究生院
<Route author="junfengP Seiry Xm798" example="/nuaa/yjsy/tzgg" path="/nuaa/yjsy/:getDescription?" :paramsDesc="['分类名', '是否获取全文']" puppeteer="1">
<Route author="junfengP Seiry Xm798" example="/nuaa/yjsy/tzgg/getDescription" path="/nuaa/yjsy/:type/:getDescription?" :paramsDesc="['分类名,见下表', '是否获取全文']" puppeteer="1" radar="1">
| 通知公告 | 新闻动态 | 学术信息 | 师生风采 |
| ---- | ---- | ---- | ---- |
@ -1831,7 +1831,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
### 自动化学院
<Route author="Seiry qrzbing Xm798" example="/nuaa/cae/zhxw" path="/nuaa/cs/:type/:getDescription?" :paramsDesc="['分类名', '是否获取全文']" puppeteer="1">
<Route author="Xm798" example="/nuaa/cae/zhxw" path="/nuaa/cs/:type/:getDescription?" :paramsDesc="['分类名,见下表', '是否获取全文']" puppeteer="1" radar="1">
| 综合新闻 | 党委行政 | 人事 / 合作 | 研究生培养 | 本科生培养 | 学生工作 | 通知公告 | 学术信息 | 答辩公告 |
| ---- | ---- | ------- | ----- | ----- | ---- | ---- | ---- | ---- |
@ -1839,7 +1839,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
### 计算机科学与技术学院
<Route author="LogicJake Seiry qrzbing Xm798" example="/nuaa/cs/jxdt" path="/nuaa/cs/:type/:getDescription?" :paramsDesc="['分类名', '是否获取全文']" puppeteer="1">
<Route author="LogicJake Seiry qrzbing Xm798" example="/nuaa/cs/jxdt" path="/nuaa/cs/:type/:getDescription?" :paramsDesc="['分类名,见下表', '是否获取全文']" puppeteer="1" radar="1">
| 通知公告 | 热点新闻 | 学科科研 | 教学动态 | 本科生培养 | 研究生培养 | 学生工作 |
| ---- | ---- | ---- | ---- | ----- | ----- | ---- |

View File

@ -43,36 +43,30 @@ module.exports = async (ctx) => {
.get();
const out = await Promise.all(
list.map((info) => {
const title = info.title || 'zhxw';
list.map(async (info) => {
const title = info.title || 'tzgg';
const date = info.date;
const itemUrl = new URL(info.link, host).href;
let description = title + '<br><a href="' + itemUrl + '" target="_blank">查看原文</a>';
return ctx.cache.tryGet(itemUrl, async () => {
const arr = itemUrl.split('.');
const pageType = arr[arr.length - 1];
// 南航新 WAF 过于敏感
// 目前 description 需要遍历页面,会被 WAF 拦截导致无法输出
// 考虑换一种获取 description 的方式或者将标题当作 title。
let description = title + '<br><a href="' + itemUrl + '" target="_blank">查看原文</a>';
if (getDescription) {
description = itemUrl;
if (getDescription) {
description = await ctx.cache.tryGet(itemUrl, async () => {
const arr = itemUrl.split('.');
const pageType = arr[arr.length - 1];
if (pageType === 'htm' || pageType === 'html') {
const response = await got(itemUrl, gotConfig);
const $ = cheerio.load(response.data);
description = $('.wp_articlecontent').html() + '<br><hr /><a href="' + itemUrl + '" target="_blank">查看原文</a>';
return $('.wp_articlecontent').html() + '<br><hr /><a href="' + itemUrl + '" target="_blank">查看原文</a>';
}
}
});
}
const single = {
title,
link: itemUrl,
description,
pubDate: parseDate(date),
};
return single;
});
return {
title,
link: itemUrl,
description,
pubDate: parseDate(date),
};
})
);

View File

@ -42,39 +42,30 @@ module.exports = async (ctx) => {
.get();
const out = await Promise.all(
list.map((info) => {
list.map(async (info) => {
const title = info.title || 'tzgg';
const date = info.date;
const itemUrl = new URL(info.link, host).href;
let description = title + '<br><a href="' + itemUrl + '" target="_blank">查看原文</a>';
return ctx.cache.tryGet(itemUrl, async () => {
const arr = itemUrl.split('.');
const pageType = arr[arr.length - 1];
// 南航新 WAF 过于敏感
// 目前 description 需要遍历页面,会被 WAF 拦截导致无法输出
// 考虑换一种获取 description 的方式或者将标题当作 title。
let description = title;
if (getDescription) {
description = itemUrl;
if (getDescription) {
description = await ctx.cache.tryGet(itemUrl, async () => {
const arr = itemUrl.split('.');
const pageType = arr[arr.length - 1];
if (pageType === 'htm' || pageType === 'html') {
const response = await got.get(itemUrl, gotConfig);
const response = await got(itemUrl, gotConfig);
const $ = cheerio.load(response.data);
description = $('.wp_articlecontent')
.html()
.replace(/src="\//g, `src="${new URL('.', host).href}`)
.trim();
return $('.wp_articlecontent').html() + '<br><hr /><a href="' + itemUrl + '" target="_blank">查看原文</a>';
}
}
});
}
const single = {
title,
link: itemUrl,
description,
pubDate: parseDate(date),
};
return single;
});
return {
title,
link: itemUrl,
description,
pubDate: parseDate(date),
};
})
);

View File

@ -40,36 +40,30 @@ module.exports = async (ctx) => {
.get();
const out = await Promise.all(
list.map((info) => {
list.map(async (info) => {
const title = info.title || 'tzgg';
const date = info.date;
const itemUrl = new URL(info.link, host).href;
let description = title + '<br><a href="' + itemUrl + '" target="_blank">查看原文</a>';
return ctx.cache.tryGet(itemUrl, async () => {
const arr = itemUrl.split('.');
const pageType = arr[arr.length - 1];
// 南航新 WAF 过于敏感
// 目前 description 需要遍历页面,会被 WAF 拦截导致无法输出
// 考虑换一种获取 description 的方式或者将标题当作 title。
let description = title + '<br><a href="' + itemUrl + '" target="_blank">查看原文</a>';
if (getDescription) {
description = itemUrl;
if (getDescription) {
description = await ctx.cache.tryGet(itemUrl, async () => {
const arr = itemUrl.split('.');
const pageType = arr[arr.length - 1];
if (pageType === 'htm' || pageType === 'html') {
const response = await got(itemUrl, gotConfig);
const $ = cheerio.load(response.data);
description = $('.wp_articlecontent').html() + '<br><hr /><a href="' + itemUrl + '" target="_blank">查看原文</a>';
return $('.wp_articlecontent').html() + '<br><hr /><a href="' + itemUrl + '" target="_blank">查看原文</a>';
}
}
});
}
const single = {
title,
link: itemUrl,
description,
pubDate: parseDate(date),
};
return single;
});
return {
title,
link: itemUrl,
description,
pubDate: parseDate(date),
};
})
);

View File

@ -1,6 +1,6 @@
module.exports = {
'/cae/:type/:getDescription?': ['Seiry', 'qrzbing', 'Xm798'],
'/cs/:type/:getDescription?': ['LogicJake', 'Seiry', 'qrzbing'],
'/cae/:type/:getDescription?': ['Xm798'],
'/cs/:type/:getDescription?': ['LogicJake', 'Seiry', 'qrzbing', 'Xm798'],
'/jwc/:type/:getDescription?': ['arcosx', 'Seiry', 'qrzbing', 'Xm798'],
'/yjsy/:type/:getDescription?': ['junfengP', 'Seiry', 'Xm798'],
};

View File

@ -38,36 +38,30 @@ module.exports = async (ctx) => {
.get();
const out = await Promise.all(
list.map((info) => {
list.map(async (info) => {
const title = info.title || 'tzgg';
const date = info.date;
const itemUrl = new URL(info.link, host).href;
let description = title + '<br><a href="' + itemUrl + '" target="_blank">查看原文</a>';
return ctx.cache.tryGet(itemUrl, async () => {
const arr = itemUrl.split('.');
const pageType = arr[arr.length - 1];
// 南航新 WAF 过于敏感
// 目前 description 需要遍历页面,会被 WAF 拦截导致无法输出
// 考虑换一种获取 description 的方式或者将标题当作 title。
let description = title + '<br><a href="' + itemUrl + '" target="_blank">查看原文</a>';
if (getDescription) {
description = itemUrl;
if (getDescription) {
description = await ctx.cache.tryGet(itemUrl, async () => {
const arr = itemUrl.split('.');
const pageType = arr[arr.length - 1];
if (pageType === 'htm' || pageType === 'html') {
const response = await got(itemUrl, gotConfig);
const $ = cheerio.load(response.data);
description = $('.wp_articlecontent').html() + '<br><hr /><a href="' + itemUrl + '" target="_blank">查看原文</a>';
return $('.wp_articlecontent').html() + '<br><hr /><a href="' + itemUrl + '" target="_blank">查看原文</a>';
}
}
});
}
const single = {
title,
link: itemUrl,
description,
pubDate: parseDate(date),
};
return single;
});
return {
title,
link: itemUrl,
description,
pubDate: parseDate(date),
};
})
);