diff --git a/lib/routes/douban/replies.js b/lib/routes/douban/replies.js index 6f1ba0b9e..8e9555110 100644 --- a/lib/routes/douban/replies.js +++ b/lib/routes/douban/replies.js @@ -34,25 +34,22 @@ module.exports = async (ctx) => { method: 'get', url: item.link, }); - const content = cheerio.load(detailResponse.data); - const commentsConfig = content('script').eq(16).html().replace('var _COMMENTS_CONFIG =', ''); - const comments = JSON.parse(commentsConfig.match(/'comments':(.*?)}],/)[1] + '}]'); - let title, description, pubDate; + const comments = JSON.parse(detailResponse.data.match(/'comments':(.*)}],/)[1] + '}]'); for (const c of comments) { if (c.id === item.link.split('#')[1]) { - (title = `${c.author.name} 于 ${c.create_time} 的回应`), (description = c.text); - pubDate = new Date(c.create_time + ' GMT+8').toUTCString(); - break; + return { + link: item.link, + title: `${c.author.name} 于 ${c.create_time} 的回应`, + pubDate: new Date(c.create_time + ' GMT+8').toUTCString(), + description: c.text, + author: c.author.name, + }; + } else if (c.replies.length > 0) { + comments.push(...c.replies); } } - - item.title = title; - item.description = description; - item.pubDate = pubDate; - - return item; }) ) );