From 7ad43e7aece390c76ed3f2d2ae41db0ebb3c9888 Mon Sep 17 00:00:00 2001 From: Laam Pui Date: Sat, 14 Nov 2020 05:11:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=99=8E=E5=97=85=E7=BD=91=E6=96=87?= =?UTF-8?q?=E5=AD=97=E4=B8=8D=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=20#6165?= =?UTF-8?q?=20(#6167)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/huxiu/utils.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/routes/huxiu/utils.js b/lib/routes/huxiu/utils.js index 608b60210b..f6256b413a 100644 --- a/lib/routes/huxiu/utils.js +++ b/lib/routes/huxiu/utils.js @@ -15,6 +15,14 @@ const ProcessFeed = async (list, cache) => { const $ = cheerio.load(response.data); + const __INITIAL_STATE__ = Function( + 'let window={};' + + $('*') + .html() + .match(/window\.__INITIAL_STATE__.*};/gm)[0] + + 'return window.__INITIAL_STATE__' + )(); + $('.article__content') .find('.lazyImg') .each((i, e) => { @@ -34,9 +42,8 @@ const ProcessFeed = async (list, cache) => { let description = ''; - const videoMatch = response.data.match(/"hd_link":"(.*)"/); - if (videoMatch !== null) { - description += ``; + if ('video_info' in __INITIAL_STATE__.articleDetail.articleDetail) { + description += ``; } if ($('.top-img').html() !== null) { description += $('.top-img').html();