From 2b26dcced5cf25424dfed2b8261805512ce4ec77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=89=E5=87=89?= Date: Wed, 14 Nov 2018 14:21:07 +0800 Subject: [PATCH] =?UTF-8?q?Enhancement:=20=E7=9F=A5=E4=B9=8E=20(#1134)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 增加知乎书店、知乎想法-24小时新闻汇总 - 顺便修复了 commit log 过长的 bug 🌚 --- docs/README.md | 4 ++++ router.js | 2 ++ routes/zhihu/bookstore/newest.js | 30 ++++++++++++++++++++++++++++++ routes/zhihu/pin/daily.js | 18 ++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 routes/zhihu/bookstore/newest.js create mode 100644 routes/zhihu/pin/daily.js diff --git a/docs/README.md b/docs/README.md index cc295251d..a586f06b9 100644 --- a/docs/README.md +++ b/docs/README.md @@ -423,6 +423,10 @@ RSSHub 提供下列 API 接口: + + + + ### pixiv diff --git a/router.js b/router.js index 13510474d..21920b4d7 100644 --- a/router.js +++ b/router.js @@ -169,6 +169,8 @@ router.get('/zhihu/pin/hotlist', require('./routes/zhihu/pin/hotlist')); router.get('/zhihu/question/:questionId', require('./routes/zhihu/question')); router.get('/zhihu/topic/:topicId', require('./routes/zhihu/topic')); router.get('/zhihu/people/pins/:id', require('./routes/zhihu/pin/people')); +router.get('/zhihu/bookstore/newest', require('./routes/zhihu/bookstore/newest')); +router.get('/zhihu/pin/daily', require('./routes/zhihu/pin/daily')); // 妹子图 router.get('/mzitu/home/:type?', require('./routes/mzitu/home')); diff --git a/routes/zhihu/bookstore/newest.js b/routes/zhihu/bookstore/newest.js new file mode 100644 index 000000000..02a7463c8 --- /dev/null +++ b/routes/zhihu/bookstore/newest.js @@ -0,0 +1,30 @@ +const axios = require('../../../utils/axios'); + +module.exports = async (ctx) => { + const response = await axios({ + method: 'get', + url: 'https://api.zhihu.com/books/features/new', + }); + + const data = response.data.data; + + ctx.state.data = { + title: '知乎书店-新书抢鲜', + link: 'https://www.zhihu.com/pub/features/new', + item: data.map((item) => { + const authors = item.authors.map((author) => author.name).join('、'); + + return { + title: item.title, + link: item.url, + description: ` +
+ ${item.title}
+ 作者: ${authors}

+ ${item.description}

+ 价格: ${item.promotion.price / 100}元 + `, + }; + }), + }; +}; diff --git a/routes/zhihu/pin/daily.js b/routes/zhihu/pin/daily.js new file mode 100644 index 000000000..685494eb1 --- /dev/null +++ b/routes/zhihu/pin/daily.js @@ -0,0 +1,18 @@ +const axios = require('../../../utils/axios'); +const { generateData } = require('./utils'); + +module.exports = async (ctx) => { + const { + data: { data }, + } = await axios({ + method: 'get', + url: 'https://api.zhihu.com/pins/special/972884951192113152/moments?order_by=newest&reverse_order=0&limit=20', + }); + + ctx.state.data = { + title: '知乎想法-24小时新闻汇总', + link: 'https://www.zhihu.com/pin/special/972884951192113152', + description: '汇集每天的社会大事、行业资讯,让你用最简单的方式获得想法里的新闻', + item: generateData(data), + }; +};