Skip to content

Commit

Permalink
fix(route): update arknights news fetch (DIYgod#7435)
Browse files Browse the repository at this point in the history
  • Loading branch information
xfoxfu authored May 12, 2021
1 parent b3ff9a7 commit b689e95
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/routes/arknights/news.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b689e95

Please sign in to comment.