fix: 虎嗅网文字不显示问题 #6165 (#6167)

This commit is contained in:
Laam Pui 2020-11-14 05:11:19 +08:00 committed by GitHub
parent b8984e5eba
commit 7ad43e7aec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions

View File

@ -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 += `<video height="100%" controls="controls" src="${videoMatch[1].replace(/\\u002F/g, '/')}"></video>`;
if ('video_info' in __INITIAL_STATE__.articleDetail.articleDetail) {
description += `<video height="100%" cover="${__INITIAL_STATE__.articleDetail.articleDetail.video_info.cover}" controls src="${__INITIAL_STATE__.articleDetail.articleDetail.video_info.hd_link}"></video>`;
}
if ($('.top-img').html() !== null) {
description += $('.top-img').html();