From 7b96a4579c8bfbab99e78f81d3e81f8458969831 Mon Sep 17 00:00:00 2001 From: Luyu Huang Date: Sun, 8 Dec 2019 02:37:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20lazy-load=20images=20cannot=20be=20displ?= =?UTF-8?q?ayed=20in=20=E4=B8=89=E7=95=8C=E5=BC=82=E6=AC=A1=E5=85=83=20(#3?= =?UTF-8?q?535)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/anime.md | 2 +- lib/routes/3ycy/home.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/anime.md b/docs/anime.md index f2c496e74..8dd1cf93c 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -233,7 +233,7 @@ pageClass: routes ### 三界异次元 - + ## 鼠绘漫画 diff --git a/lib/routes/3ycy/home.js b/lib/routes/3ycy/home.js index e1f5199c5..7b323f30b 100644 --- a/lib/routes/3ycy/home.js +++ b/lib/routes/3ycy/home.js @@ -33,12 +33,21 @@ module.exports = async (ctx) => { const res = await got({ method: 'get', url: url.resolve(root_url, link) }); const content = cheerio.load(res.data); + const post = content('div.postBody'); + post.find('img[data-src]').each((_, ele) => { + ele = content(ele); + ele.attr('src', ele.attr('data-src')); + ele.attr('alt', title.text()); + ele.attr('title', title.text()); + ele.removeAttr('class'); + ele.removeAttr('data-src'); + }); return { title: title.text(), link: link, pubDate: pubDate, - description: content('div.postBody').html(), + description: post.html(), }; }); })