diff --git a/lib/v2/uibe/hr.js b/lib/v2/uibe/hr.js index b1cac947b..2afd63cad 100644 --- a/lib/v2/uibe/hr.js +++ b/lib/v2/uibe/hr.js @@ -16,30 +16,34 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); - const list = $('.lawul, .longul') + let items = $('.lawul, .longul') .find('li a') - .map((_, item) => { + .toArray() + .map((item) => { item = $(item); return { title: item.find('p').text(), link: `${currentUrl}/${item.attr('href')}`, }; - }) - .get(); + }); - const items = await Promise.all( - list.map((item) => + items = await Promise.all( + items.map((item) => ctx.cache.tryGet(item.link, async () => { - const detailResponse = await got({ - method: 'get', - url: item.link, - }); + try { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); - const content = cheerio.load(detailResponse.data); + const content = cheerio.load(detailResponse.data); - item.description = content('.gp-article').html(); - item.pubDate = parseDate(content('#shareTitle').next().text().replace('时间:', '')); + item.description = content('.gp-article').html(); + item.pubDate = parseDate(content('#shareTitle').next().text().replace('时间:', '')); + } catch (err) { + item.description = 'Not Found'; + } return item; })