fix(route): update arknights news fetch (#7435)

This commit is contained in:
小傅Fox 2021-05-12 12:34:53 +08:00 committed by GitHub
parent b3ff9a7fbb
commit b689e95e27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -10,23 +10,24 @@ module.exports = async (ctx) => {
let newslist = response.data;
const $ = cheerio.load(newslist);
newslist = $('#news > div > div.news-block > ul:first-child > li');
newslist = $('.articleItem > .articleItemLink');
newslist = await Promise.all(
newslist
.slice(0, 9) // limit article count to a single page
.map(async (index, item) => {
const sth = $(item);
const link = `https://ak.hypergryph.com${sth.find('a').attr('href').slice(1)}`;
const link = `https://ak.hypergryph.com${sth.attr('href')}`;
const description = await ctx.cache.tryGet(link, async () => {
const result = await got.get(link);
const $ = cheerio.load(result.data);
return $('.article-inner').html();
return $('.article-content').html();
});
return {
title: sth.find('.news-title').first().text(),
title: `[${sth.find('.articleItemCate').first().text()}] ${sth.find('.articleItemTitle').first().text()}`,
description,
link,
pubDate: new Date(sth.find('.news-date-text').first().text()),
pubDate: new Date(sth.find('.articleItemDate').first().text()),
};
})
.get()