From 70d53468a5cebcfa3faa11d377ff238367b4ff88 Mon Sep 17 00:00:00 2001 From: Cloud Date: Thu, 8 Aug 2019 21:52:27 +0800 Subject: [PATCH] fix: chouti (#2789) --- lib/routes/chouti/index.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/routes/chouti/index.js b/lib/routes/chouti/index.js index 25e9b6e4c9..4f42602062 100644 --- a/lib/routes/chouti/index.js +++ b/lib/routes/chouti/index.js @@ -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}

评论`, + description: `${item.title}

评论`, 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, }; };