feat: pediy filter top topics (#5335)

This commit is contained in:
hellodword 2020-08-03 04:34:17 +08:00 committed by GitHub
parent 01e631b784
commit 7ed0ed6787
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -55,12 +55,17 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const list = $('.thread');
const resultItem = await Promise.all(
list
? list
// fix .thread .top_3
.filter((_, elem) => {
const pubDate = pediyUtils.dateParser($('.date', elem).eq(0).text(), 8);
return elem.attribs.class.indexOf('top') === -1 || new Date() - new Date(pubDate) < 1000 * 60 * 60 * 24 * 3;
})
.map(async (_, elem) => {
const subject = $('.subject a', elem).eq(1);
const pubDate = pediyUtils.dateParser($('.date', elem).eq(0).text(), 8);
const link = `${baseUrl}${subject.attr('href')}`;