From 0aeee4fa999bf853325d2d40b20d7d68463c5f6e Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Mon, 14 Dec 2020 19:50:48 +0800 Subject: [PATCH] fix: latest comments from lowendtalk discussions (#6437) --- lib/routes/lowendtalk/discussion.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/routes/lowendtalk/discussion.js b/lib/routes/lowendtalk/discussion.js index f0f7c563d..148dabdb1 100644 --- a/lib/routes/lowendtalk/discussion.js +++ b/lib/routes/lowendtalk/discussion.js @@ -4,12 +4,19 @@ const cheerio = require('cheerio'); module.exports = async (ctx) => { const rootUrl = 'https://www.lowendtalk.com'; const currentUrl = `${rootUrl}/discussion/${ctx.params.id}`; - const response = await got({ + let response = await got({ method: 'get', url: currentUrl, }); - const $ = cheerio.load(response.data); + let $ = cheerio.load(response.data); + + response = await got({ + method: 'get', + url: $('.LastPage').attr('href'), + }); + + $ = cheerio.load(response.data); const items = $('.userContent') .map((_, item) => { @@ -29,7 +36,7 @@ module.exports = async (ctx) => { .get(); ctx.state.data = { - title: $('title').text(), + title: $('h1').eq(0).text(), link: currentUrl, item: items, };