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, };