From 8b88feff0ff40e0b968d18b1f3528689a8591362 Mon Sep 17 00:00:00 2001 From: Jaya <82650452+real-jiakai@users.noreply.github.com> Date: Fri, 11 Nov 2022 16:43:12 +0800 Subject: [PATCH] fix njxzc tzgg (#11253) Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> --- lib/v2/njxzc/home.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/v2/njxzc/home.js b/lib/v2/njxzc/home.js index 6c877f9f7..640db5ef6 100644 --- a/lib/v2/njxzc/home.js +++ b/lib/v2/njxzc/home.js @@ -36,15 +36,19 @@ module.exports = async (ctx) => { // 使用缓存 ctx.cache.tryGet(item.link, async () => { const response = await got(item.link); - const $ = cheerio.load(response.data); - item.title = $('.arti_title').text(); - item.description = $('.wp_articlecontent') - .html() - .replace(/src="\//g, `src="${new URL('.', host).href}`) - .replace(/href="\//g, `href="${new URL('.', host).href}`) - .trim(); - item.pubDate = timezone(parseDate($('.arti_update').text().replace('发布时间:', '')), +8); - + if (response.redirectUrls.length > 0) { + item.link = response.redirectUrls[0]; + item.description = '该通知无法直接预览,请点击原文链接↑查看'; + } else { + const $ = cheerio.load(response.data); + item.title = $('.arti_title').text(); + item.description = $('.wp_articlecontent') + .html() + .replace(/src="\//g, `src="${new URL('.', host).href}`) + .replace(/href="\//g, `href="${new URL('.', host).href}`) + .trim(); + item.pubDate = timezone(parseDate($('.arti_update').text().replace('发布时间:', '')), +8); + } return item; }) )