fix: 喷嚏 DOM 更新 (#5022)

This commit is contained in:
Henry Wang 2020-06-22 04:43:52 +01:00 committed by GitHub
parent 4028de9a86
commit 0cf12554b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 6 deletions

View File

@ -35,14 +35,24 @@ module.exports = {
responseType: 'buffer',
});
const convert_data = iconv.decode(original_data.data, 'gbk');
const detail_data = cheerio
.load(convert_data, {
decodeEntities: false,
})('div[class="oblog_text"]')
.html();
const description = cheerio.load(convert_data, {
decodeEntities: false,
})('body > table > tbody > tr > td.oblog_t_2 > div > table > tbody > tr:nth-child(2) > td');
description.find('table, .adsbygoogle').remove();
// remove header
const count = subjectid.toString() === '70' ? 8 : 3;
for (let index = 0; index < count; index++) {
description.children().first().remove();
}
// remove footer
for (let index = 0; index < 8; index++) {
description.children().last().remove();
}
const single = {
title: el.text(),
description: detail_data,
description: description.html(),
link: url,
};
return Promise.resolve(single);