fix(route): nbd (#11847)

This commit is contained in:
Tony 2023-02-12 08:31:30 -06:00 committed by GitHub
parent e0c41d3c75
commit 00bafcd6fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

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