From 46bdcb18cc34199db77f758cafd03a5d26aad278 Mon Sep 17 00:00:00 2001 From: mjysci Date: Fri, 22 Jan 2021 11:41:45 +0800 Subject: [PATCH] =?UTF-8?q?ref:=20=E7=BD=91=E6=98=93=E5=8F=B7=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=85=A8=E6=96=87=E8=8E=B7=E5=8F=96=20(#6753)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 适当调整了获取数量 --- lib/routes/netease/dy2.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/routes/netease/dy2.js b/lib/routes/netease/dy2.js index fe81eb76d..c9344bbf5 100644 --- a/lib/routes/netease/dy2.js +++ b/lib/routes/netease/dy2.js @@ -12,7 +12,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(data, { decodeEntities: false }); const list = $('.media_articles ul li') - .slice(0, 3) + .slice(0, 5) .map((_, item) => { item = $(item); const a = item.find('h2.media_article_title a'); @@ -44,8 +44,16 @@ module.exports = async (ctx) => { ); content = cheerio.load(itemData, { decodeEntities: false }); } else { - const response = await got.get(item.link); - content = cheerio.load(response.data, { decodeEntities: false }); + const itemData = await ctx.cache.tryGet( + item.link, + async () => + ( + await got.get(item.link, { + responseType: 'buffer', + }) + ).data + ); + content = cheerio.load(itemData, { decodeEntities: false }); } const eDescription = content('.post_body').html();