fix: 修正微信公众号路由(传送门来源以及CareerEngine来源)中的图片链接 (#4590)

This commit is contained in:
lightyears
2020-04-28 23:42:08 +08:00
committed by GitHub
parent 853f00ee25
commit 4a3ac0ce45
2 changed files with 15 additions and 2 deletions

View File

@@ -12,10 +12,18 @@ module.exports = async (ctx) => {
const response = await got.get(item.link);
const $ = cheerio.load(response.data);
const post = $('.post');
post.find('img').each((_, img) => {
const dataSrc = $(img).attr('data-src');
if (dataSrc) {
$(img).attr('src', dataSrc);
}
});
const single = {
title: item.title,
description: $('.post').html(),
description: post.html(),
pubDate: item.pubDate,
link: item.link,
};