fix: conditional cache in wenxuemi router (#2770)

This commit is contained in:
Ving
2019-08-05 11:28:16 +08:00
committed by DIYgod
parent a359c85c46
commit cba113f703
+8 -3
View File
@@ -39,14 +39,19 @@ module.exports = async (ctx) => {
const articleHtml = await got_ins.get(link);
const article = iconv.decode(articleHtml.data, 'GBK');
const $1 = cheerio.load(article);
const res = $1('div#content').html();
const res = $1('div#content');
resultItem = {
title: $item.text(),
description: res,
description: res.html(),
link: link,
};
if (res.slice(0, 10).includes('正在手打中') === false) {
if (
res
.text()
.slice(0, 10)
.includes('正在手打中') === false
) {
ctx.cache.set(link, JSON.stringify(resultItem));
}
}