fix: slice issue (#3855)

This commit is contained in:
EsuRt 2020-02-02 13:58:12 +08:00 committed by GitHub
parent b833b99467
commit 70d40284c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 20 deletions

View File

@ -44,7 +44,7 @@ module.exports = async (ctx) => {
link: url,
item: await Promise.all(
list
.slice(1, 12)
.slice(0, 12)
.map(async (index, item) => {
item = $(item);
let fullText = '';

View File

@ -11,24 +11,23 @@ module.exports = async (ctx) => {
title: '国务院 - 吹风会',
link: link,
item: await Promise.all(
list &&
list
.slice(1, 12)
.map(async (index, item) => {
item = $(item);
const contenlUrl = item.find('a').attr('href');
const description = await ctx.cache.tryGet(contenlUrl, async () => {
const fullText = await got.get(contenlUrl);
const fullTextData = cheerio.load(fullText.data);
return fullTextData('.online_list').html();
});
return {
title: item.find('a').text(),
description: description,
link: contenlUrl,
};
})
.get()
list
.slice(0, 12)
.map(async (index, item) => {
item = $(item);
const contenlUrl = item.find('a').attr('href');
const description = await ctx.cache.tryGet(contenlUrl, async () => {
const fullText = await got.get(contenlUrl);
const fullTextData = cheerio.load(fullText.data);
return fullTextData('.online_list').html();
});
return {
title: item.find('a').text(),
description: description,
link: contenlUrl,
};
})
.get()
),
};
};

View File

@ -13,7 +13,7 @@ module.exports = async (ctx) => {
link: link,
item: await Promise.all(
list
.slice(1, 12)
.slice(0, 12)
.map(async (index, item) => {
item = $(item);
// 获取全文