From 32b3c5892c35dd24a2e33d977ca37142a447cc6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=89=E5=87=89?= Date: Wed, 17 Oct 2018 11:11:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=EF=BC=9A=E7=9F=A5=E4=B9=8E-?= =?UTF-8?q?=E6=83=B3=E6=B3=95=E7=83=AD=E6=A6=9C=20(#909)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 2 ++ router.js | 1 + routes/zhihu/pin/hotlist.js | 59 +++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 routes/zhihu/pin/hotlist.js diff --git a/docs/README.md b/docs/README.md index 7348ae84a9..6917f38421 100644 --- a/docs/README.md +++ b/docs/README.md @@ -402,6 +402,8 @@ RSSHub 提供下列 API 接口: + + ### pixiv diff --git a/router.js b/router.js index fc668799a2..67401c73a6 100644 --- a/router.js +++ b/router.js @@ -162,6 +162,7 @@ router.get('/zhihu/people/answers/:id', require('./routes/zhihu/answers')); router.get('/zhihu/zhuanlan/:id', require('./routes/zhihu/zhuanlan')); router.get('/zhihu/daily', require('./routes/zhihu/daily')); router.get('/zhihu/hotlist', require('./routes/zhihu/hotlist')); +router.get('/zhihu/pin/hotlist', require('./routes/zhihu/pin/hotlist')); // 妹子图 router.get('/mzitu', require('./routes/mzitu/category')); diff --git a/routes/zhihu/pin/hotlist.js b/routes/zhihu/pin/hotlist.js new file mode 100644 index 0000000000..236af869d2 --- /dev/null +++ b/routes/zhihu/pin/hotlist.js @@ -0,0 +1,59 @@ +const axios = require('../../../utils/axios'); + +module.exports = async (ctx) => { + const { + data: { data }, + } = await axios({ + method: 'get', + url: 'https://api.zhihu.com/pins/hot_list?reverse_order=0', + }); + + ctx.state.data = { + title: '知乎想法热榜', + description: '整点更新', + item: data.map(({ target }) => { + const pubDate = new Date(target.created * 1000).toUTCString(); + const author = target.author.name; + const title = `${author}:${target.excerpt_title}`; + const link = `https://www.zhihu.com/pin/${target.id}`; + const description = target.content.reduce((description, item) => { + switch (item.type) { + case 'text': + description += `
${item.content}
`; + break; + + case 'image': + description += ``; + break; + + case 'video': + description += `