From cba113f703dad973afe498d393b74423148dd753 Mon Sep 17 00:00:00 2001 From: Ving Date: Mon, 5 Aug 2019 11:28:16 +0800 Subject: [PATCH] fix: conditional cache in wenxuemi router (#2770) --- lib/routes/novel/wenxuemi.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/routes/novel/wenxuemi.js b/lib/routes/novel/wenxuemi.js index 1c637c7706..7d33e65357 100644 --- a/lib/routes/novel/wenxuemi.js +++ b/lib/routes/novel/wenxuemi.js @@ -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)); } }