mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-16 11:37:44 +08:00
@@ -404,6 +404,8 @@ RSSHub 提供下列 API 接口:
|
||||
|
||||
<route name="知乎想法热榜" author="xyqfer" example="/zhihu/pin/hotlist" path="/zhihu/pin/hotlist"/>
|
||||
|
||||
<route name="问题" author="xyqfer" example="/zhihu/question/59895982" path="/zhihu/question/:questionId" :paramsDesc="['问题 id']"/>
|
||||
|
||||
### pixiv
|
||||
|
||||
<route name="用户收藏" author="EYHN" example="/pixiv/user/bookmarks/15288095" path="/pixiv/user/bookmarks/:id" :paramsDesc="['用户 id, 可在用户主页 URL 中找到']"/>
|
||||
|
||||
@@ -163,6 +163,7 @@ 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('/zhihu/question/:questionId', require('./routes/zhihu/question'));
|
||||
|
||||
// 妹子图
|
||||
router.get('/mzitu', require('./routes/mzitu/category'));
|
||||
|
||||
38
routes/zhihu/question.js
Normal file
38
routes/zhihu/question.js
Normal file
@@ -0,0 +1,38 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { questionId } = ctx.params;
|
||||
const sort = 'created';
|
||||
const limit = 20;
|
||||
const include = `data[*].content.excerpt&limit=${limit}&offset=0`;
|
||||
const url = `https://www.zhihu.com/api/v4/questions/${questionId}/answers?include=${include}&sort_by=${sort}`;
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url,
|
||||
headers: {
|
||||
...utils.header,
|
||||
Referer: `https://www.zhihu.com/question/${questionId}`,
|
||||
Authorization: 'oauth c3cef7c66a1843f8b3a9e6a1e3160e20', // hard-coded in js
|
||||
},
|
||||
});
|
||||
const listRes = response.data.data;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `知乎-${listRes[0].question.title}`,
|
||||
link: `https://www.zhihu.com/question/${questionId}`,
|
||||
item: listRes.map((item) => {
|
||||
const title = `${item.author.name}的回答:${item.excerpt}`;
|
||||
const description = `${item.author.name}的回答<br/><br/>${utils.ProcessImage(item.content)}`;
|
||||
|
||||
return {
|
||||
title,
|
||||
description,
|
||||
author: item.author.name,
|
||||
pubDate: new Date(item.updated_time * 1000).toUTCString(),
|
||||
guid: item.id.toString(),
|
||||
link: `https://www.zhihu.com/question/${questionId}/answer/${item.id}`,
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user