From b82e8fe713fcdab5d46a8ee6dc3cc3de34fac5b6 Mon Sep 17 00:00:00 2001 From: Cloud Date: Wed, 18 Sep 2019 10:58:46 +0800 Subject: [PATCH] fix: jianshu can't get fulltext and pubDate (#3104) --- lib/routes/jianshu/utils.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/routes/jianshu/utils.js b/lib/routes/jianshu/utils.js index 63d8882b6e..1754d0f785 100644 --- a/lib/routes/jianshu/utils.js +++ b/lib/routes/jianshu/utils.js @@ -8,11 +8,7 @@ async function load(link) { const $ = cheerio.load(response.data); // 解析日期 - const date = new Date( - $('.publish-time') - .text() - .match(/\d{4}.\d{2}.\d{2} \d{2}:\d{2}/) - ); + const date = new Date($('time').attr('datetime')); const timeZone = 8; const serverOffset = date.getTimezoneOffset() / 60; const pubDate = new Date(date.getTime() - 60 * 60 * 1000 * (timeZone + serverOffset)).toUTCString(); @@ -31,7 +27,7 @@ async function load(link) { `); }); // 提取内容 - const description = $('.show-content-free').html(); + const description = $('article').html(); return { description, pubDate }; }