fix njxzc tzgg (#11253)

Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com>
This commit is contained in:
Jaya 2022-11-11 16:43:12 +08:00 committed by GitHub
parent 92e675464b
commit 8b88feff0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 9 deletions

View File

@ -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;
})
)