fix: chouti (#2789)

This commit is contained in:
Cloud
2019-08-08 21:52:27 +08:00
committed by DIYgod
parent 669e5a1895
commit 70d53468a5
+10 -8
View File
@@ -1,33 +1,35 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
let { subject = '' } = ctx.params;
const subject = ctx.params.subject || 'hot';
const host = 'https://m.chouti.com';
let api = `${host}/api/m/zone/${subject}?afterTime=0`;
let pageUrl = `https://m.chouti.com/zone/${subject}`;
if (subject === 'hot') {
subject = '';
api = `${host}/api/m/link/hot?afterTime=0`;
pageUrl = `https://m.chouti.com/all/hot`;
}
const response = await got({
method: 'get',
url: `${host}/m/link/more.do?type=hot&subject=${subject}&limit=recent`,
url: api,
headers: {
Referer: host,
},
});
const resultItem = response.data.result.data.items.map((item) => ({
const resultItem = response.data.data.map((item) => ({
title: item.title,
author: item.nick,
description: `${item.title}<br><img src="${item.originalImgUrl}" referrerpolicy="no-referrer" /><br><a href="${host}${item.commentsUrl}">评论</a>`,
description: `${item.title}<br><img src="${item.originalImgUrl || item.imgUrl || item.original_img_url || item.img_url}" referrerpolicy="no-referrer" /><br><a href="${host}/link/${item.id}">评论</a>`,
link: item.url,
pubDate: new Date(item.createtime / 1000).toUTCString(),
pubDate: new Date(item.createdTime / 1000).toUTCString(),
}));
ctx.state.data = {
title: '抽屉新热榜',
description: '抽屉新热榜,汇聚每日搞笑段子、热门图片、有趣新闻。它将微博、门户、社区、bbs、社交网站等海量内容聚合在一起,通过用户推荐生成最热榜单。看抽屉新热榜,每日热门、有趣资讯尽收眼底。',
link: host,
link: pageUrl,
item: resultItem,
};
};