From cf031c296d6d904f703123be5c2fad3b230e296b Mon Sep 17 00:00:00 2001 From: Cloud Date: Fri, 5 Jul 2019 11:11:26 +0800 Subject: [PATCH] fix: zaker some url 302 (#2559) --- lib/routes/zaker/source.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/routes/zaker/source.js b/lib/routes/zaker/source.js index c2d77e4a3..2cba95adf 100644 --- a/lib/routes/zaker/source.js +++ b/lib/routes/zaker/source.js @@ -43,14 +43,19 @@ module.exports = async (ctx) => { Referer: link, }, }); + const $ = cheerio.load(response.data); + $('img').each((index, elem) => { const $elem = $(elem); + const src = $elem.attr('data-original'); + if (src && src !== '') { + $elem.attr('src', `${src}`); + } $elem.attr('referrerpolicy', 'no-referrer'); }); - const description = $('div.article_content div') - .html() - .replace(/data-original/g, `src`); + + const description = $('div.article_content div').html() || '原文已被删除'; const date = $('span.time').text();