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

适当调整了获取数量
This commit is contained in:
mjysci
2021-01-21 22:41:45 -05:00
committed by GitHub
parent ec7568146b
commit 46bdcb18cc
+11 -3
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();