fix: 修复重庆大学校团委某些通知正文或附件缺失 (#4834)

This commit is contained in:
郭俊余 2020-05-22 16:21:09 +08:00 committed by GitHub
parent 7bc34d27de
commit d56fd7c597
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -14,9 +14,8 @@ module.exports = async (ctx) => {
const data = response.data;
const $ = cheerio.load(data);
const links = $('div[class=nwes_list]')
.find('ul[style]') // nwes_list 原文如此
.find('a[target=_blank]')
const links = $('div[class=nwes_list]') // nwes_list 原文如此
.find('a[target=_blank]', 'ul[style]')
.map((index, item) => ({
title: item.attribs.title,
link: baseUrl + item.attribs.href,
@ -45,7 +44,9 @@ module.exports = async (ctx) => {
if (authorText && authorText.slice(0, 4) === '拟稿人:') {
item.author = authorText.slice(4);
}
item.description = newsContent.find('div[class=v_news_content]').find('div').text();
const newsText = newsContent.find('div[class=v_news_content]');
const attedText = newsText.parent().nextAll().filter('ul[style="list-style-type:none;"]');
item.description = newsText.html() + (newsContent.html(attedText).html() || '');
ctx.cache.set(item.link, JSON.stringify(item));
return Promise.resolve(item);