From 00bafcd6fef5f53f8ea2e04bc4588daf9d545478 Mon Sep 17 00:00:00 2001 From: Tony Date: Sun, 12 Feb 2023 08:31:30 -0600 Subject: [PATCH] fix(route): nbd (#11847) --- lib/v2/nbd/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/v2/nbd/index.js b/lib/v2/nbd/index.js index 1f843f439f..506649ddf5 100644 --- a/lib/v2/nbd/index.js +++ b/lib/v2/nbd/index.js @@ -7,7 +7,7 @@ module.exports = async (ctx) => { const id = ctx.params.id ?? '3'; const rootUrl = 'https://www.nbd.com.cn'; - const currentUrl = `${rootUrl}/columns/${id}`; + const currentUrl = `${rootUrl}/columns/${id}/`; const response = await got({ method: 'get', @@ -17,15 +17,15 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); const list = $('.u-news-title a') - .map((_, item) => { + .toArray() + .map((item) => { item = $(item); return { title: item.text(), - link: 'https:' + item.attr('href'), + link: item.attr('href'), }; - }) - .get(); + }); const items = await Promise.all( list.map((item) => @@ -45,7 +45,7 @@ module.exports = async (ctx) => { ); ctx.state.data = { - title: `${$('.u-channelname').text()} - 每经网`, + title: `${$('h1').text()} - 每经网`, link: currentUrl, item: items, };