From 2145b9b23c82c747259bc79cf6f0bb2fb59cde1f Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Sun, 18 Oct 2020 23:50:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BE=AE=E4=BF=A1=E5=85=AC=E4=BC=97?= =?UTF-8?q?=E5=8F=B7=E4=BA=8C=E5=8D=81=E6=AC=A1=E5=B9=82=E6=9D=A5=E6=BA=90?= =?UTF-8?q?=20(#5908)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/new-media.md | 2 +- lib/routes/tencent/wechat/ershcimi.js | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/new-media.md b/docs/new-media.md index bc00bc3bd..494abe475 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1385,7 +1385,7 @@ area 分区选项 ### 公众号 (二十次幂来源) - + ### 公众号 (外接大脑来源) diff --git a/lib/routes/tencent/wechat/ershcimi.js b/lib/routes/tencent/wechat/ershcimi.js index 165d59a4e..60b1a929a 100644 --- a/lib/routes/tencent/wechat/ershcimi.js +++ b/lib/routes/tencent/wechat/ershcimi.js @@ -6,16 +6,35 @@ module.exports = async (ctx) => { const url = `https://www.ershicimi.com/a/${id}`; const response = await got(url); const $ = cheerio.load(response.data); - const items = $('.weui_media_box') + const list = $('.weui_media_box') .map((_, ele) => { const $item = cheerio.load(ele); return { title: $item('.weui_media_title a').text(), - link: $item('.weui_media_title a').attr('href'), + description: $item('.weui_media_desc').text(), + link: `https://www.ershicimi.com${$item('.weui_media_title a').attr('href')}`, pubDate: new Date($item('.weui_media_extra_info').attr('title')).toUTCString(), }; }) .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const detailRepsonse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailRepsonse.data); + + item.description = content('.article-content').html() ? content('.article-content').html() : item.description; + + return item; + }) + ) + ); + ctx.state.data = { title: `微信公众号 - ${$('span.name').text()}`, link: url,