RSS: zhihu answers
This commit is contained in:
parent
c7b1dfef31
commit
3398fdec32
|
|
@ -42,6 +42,7 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
|
|||
- 知乎
|
||||
- 收藏夹
|
||||
- 用户动态
|
||||
- 用户回答
|
||||
- 专栏
|
||||
- 自如
|
||||
- 房源
|
||||
|
|
|
|||
|
|
@ -292,6 +292,14 @@ s
|
|||
|
||||
参数: id,用户 id,可在用户主页 URL 中找到
|
||||
|
||||
### 用户回答
|
||||
|
||||
举例: [https://rss.now.sh/zhihu/people/answers/diygod](https://rss.now.sh/zhihu/people/answers/diygod)
|
||||
|
||||
路由: `/zhihu/people/answers/:id`
|
||||
|
||||
参数: id,用户 id,可在用户主页 URL 中找到
|
||||
|
||||
### 专栏
|
||||
|
||||
举例: [https://rss.now.sh/zhihu/zhuanlan/googledevelopers](https://rss.now.sh/zhihu/zhuanlan/googledevelopers)
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ router.get('/jianshu/user/:id', require('./routes/jianshu/user'));
|
|||
// // 知乎
|
||||
router.get('/zhihu/collection/:id', require('./routes/zhihu/collection'));
|
||||
router.get('/zhihu/people/activities/:id', require('./routes/zhihu/activities'));
|
||||
router.get('/zhihu/people/answers/:id', require('./routes/zhihu/answers'));
|
||||
router.get('/zhihu/zhuanlan/:id', require('./routes/zhihu/zhuanlan'));
|
||||
|
||||
// // 贴吧
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
const axios = require('axios');
|
||||
const template = require('../../utils/template');
|
||||
const config = require('../../config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: `https://www.zhihu.com/api/v4/members/${id}/answers?include=data%5B*%5D.is_normal%2Cadmin_closed_comment%2Creward_info%2Cis_collapsed%2Cannotation_action%2Cannotation_detail%2Ccollapse_reason%2Ccollapsed_by%2Csuggest_edit%2Ccomment_count%2Ccan_comment%2Ccontent%2Cvoteup_count%2Creshipment_settings%2Ccomment_permission%2Cmark_infos%2Ccreated_time%2Cupdated_time%2Creview_info%2Cquestion%2Cexcerpt%2Crelationship.is_authorized%2Cvoting%2Cis_author%2Cis_thanked%2Cis_nothelp%3Bdata%5B*%5D.author.badge%5B%3F(type%3Dbest_answerer)%5D.topics&offset=0&limit=7&sort_by=created`,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
'Referer': `https://www.zhihu.com/people/${id}/answers`,
|
||||
'authorization': 'oauth c3cef7c66a1843f8b3a9e6a1e3160e20',
|
||||
'X-API-VERSION': '3.0.40'
|
||||
}
|
||||
});
|
||||
|
||||
const data = response.data.data;
|
||||
|
||||
ctx.body = template({
|
||||
title: `${data[0].author.name}的知乎回答`,
|
||||
link: `https://www.zhihu.com/people/${id}/answers`,
|
||||
description: data[0].author.headline || data[0].author.description,
|
||||
item: data && data.map((item) => ({
|
||||
title: item.question.title,
|
||||
description: item.content,
|
||||
pubDate: new Date(item.created_time * 1000).toUTCString(),
|
||||
link: `https://www.zhihu.com/question/${item.question.id}/answer/${item.id}`
|
||||
})),
|
||||
});
|
||||
};
|
||||
Loading…
Reference in New Issue