ref: 网易号增加全文获取 (#6753)

适当调整了获取数量
This commit is contained in:
mjysci 2021-01-22 11:41:45 +08:00 committed by GitHub
parent ec7568146b
commit 46bdcb18cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 3 deletions

View File

@ -12,7 +12,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(data, { decodeEntities: false });
const list = $('.media_articles ul li')
.slice(0, 3)
.slice(0, 5)
.map((_, item) => {
item = $(item);
const a = item.find('h2.media_article_title a');
@ -44,8 +44,16 @@ module.exports = async (ctx) => {
);
content = cheerio.load(itemData, { decodeEntities: false });
} else {
const response = await got.get(item.link);
content = cheerio.load(response.data, { decodeEntities: false });
const itemData = await ctx.cache.tryGet(
item.link,
async () =>
(
await got.get(item.link, {
responseType: 'buffer',
})
).data
);
content = cheerio.load(itemData, { decodeEntities: false });
}
const eDescription = content('.post_body').html();