diff --git a/lib/v2/guanhai/index.js b/lib/v2/guanhai/index.js index 7911aff9c..44e95278e 100644 --- a/lib/v2/guanhai/index.js +++ b/lib/v2/guanhai/index.js @@ -7,12 +7,16 @@ module.exports = async (ctx) => { const { data: response } = await got('https://www.guanhai.com.cn'); const $ = cheerio.load(response); - const imgBox = $('.img-box'); - const recommand = { - title: imgBox.find('a').first().attr('title'), - link: imgBox.find('a').first().attr('href'), - pubDate: timezone(parseDate(imgBox.find('time').text()), 8), - }; + const recommand = $('.img-box ul > a') + .toArray() + .map((item) => { + item = $(item); + return { + title: item.attr('title'), + link: item.attr('href'), + }; + }); + const list = [ ...$('.pic-summary .title') .toArray() @@ -21,11 +25,11 @@ module.exports = async (ctx) => { return { title: item.find('a').attr('title'), link: item.find('a').attr('href'), - pubDate: timezone(parseDate(item.find('time').text()), 8), + pubDate: timezone(parseDate(item.find('time').text(), 'YYYY-MM-DD HH:mm'), 8), }; }), - recommand, - ]; + ...recommand, + ].filter((item) => item.link.startsWith('http')); const items = await Promise.all( list.map((item) => @@ -33,7 +37,8 @@ module.exports = async (ctx) => { const { data: response } = await got(item.link); const $ = cheerio.load(response); item.author = $('.source').text(); - item.description = $('.article-content').html(); + item.description = $('.article-content').html() ?? $('.video-content').html(); + item.pubDate = item.pubDate ?? timezone(parseDate($('.date').text(), 'YYYY-MM-DD HH:mm'), 8); return item; }) )