fix(route): update arknights news fetch (#7435)
This commit is contained in:
parent
b3ff9a7fbb
commit
b689e95e27
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue