fix: 好奇心日报专栏 51 (#2101)

This commit is contained in:
Enoch Ma 2019-05-12 15:08:05 +08:00 committed by DIYgod
parent 7b91a6b046
commit cd63190a96
1 changed files with 14 additions and 2 deletions

View File

@ -14,11 +14,18 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map(async (item, i) => {
const $ = cheerio.load(item);
const time = $('.smart-date').attr('data-origindate');
let time = $('.smart-date').attr('data-origindate');
let title = $('.title').text();
if (!title) {
title = $('.smart-dotdotdot').text();
}
if (!title) {
const mmTitle = $('.makemoney-title').text();
const description = $('.makemoney-discription').text();
title = mmTitle + '' + description;
time = new Date();
}
const itemUrl = $('a').attr('href');
const allUrl = `http://www.qdaily.com${itemUrl}`;
const cache = await ctx.cache.get(allUrl);
@ -49,7 +56,12 @@ module.exports = async (ctx) => {
$('.article-detail-bd .author-share').remove();
$('.article-detail-ft').remove();
out[indexList[i]].description = $('.main .com-article-detail').html();
if (out[indexList[i]].link.match('/weeklies/')) {
out[indexList[i]].description = $('.packery-container').html();
} else {
out[indexList[i]].description = $('.main .com-article-detail').html();
}
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]));
}
ctx.state.data = {