mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-12 16:20:27 +08:00
增加:知乎-想法热榜 (#909)
This commit is contained in:
@@ -402,6 +402,8 @@ RSSHub 提供下列 API 接口:
|
|||||||
|
|
||||||
<route name="知乎热榜" author="DIYgod" example="/zhihu/hotlist" path="/zhihu/hotlist"/>
|
<route name="知乎热榜" author="DIYgod" example="/zhihu/hotlist" path="/zhihu/hotlist"/>
|
||||||
|
|
||||||
|
<route name="知乎想法热榜" author="xyqfer" example="/zhihu/pin/hotlist" path="/zhihu/pin/hotlist"/>
|
||||||
|
|
||||||
### pixiv
|
### pixiv
|
||||||
|
|
||||||
<route name="用户收藏" author="EYHN" example="/pixiv/user/bookmarks/15288095" path="/pixiv/user/bookmarks/:id" :paramsDesc="['用户 id, 可在用户主页 URL 中找到']"/>
|
<route name="用户收藏" author="EYHN" example="/pixiv/user/bookmarks/15288095" path="/pixiv/user/bookmarks/:id" :paramsDesc="['用户 id, 可在用户主页 URL 中找到']"/>
|
||||||
|
|||||||
@@ -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/zhuanlan/:id', require('./routes/zhihu/zhuanlan'));
|
||||||
router.get('/zhihu/daily', require('./routes/zhihu/daily'));
|
router.get('/zhihu/daily', require('./routes/zhihu/daily'));
|
||||||
router.get('/zhihu/hotlist', require('./routes/zhihu/hotlist'));
|
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'));
|
router.get('/mzitu', require('./routes/mzitu/category'));
|
||||||
|
|||||||
59
routes/zhihu/pin/hotlist.js
Normal file
59
routes/zhihu/pin/hotlist.js
Normal file
@@ -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 += `<div>${item.content}</div>`;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'image':
|
||||||
|
description += `<img referrerpolicy="no-referrer" src="${item.url.replace('_xl.', '_r.').replace('_ms.', '_r.')}" />`;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'video':
|
||||||
|
description += `<video
|
||||||
|
controls="controls"
|
||||||
|
width="${item.playlist.hd.width}"
|
||||||
|
height="${item.playlist.hd.height}"
|
||||||
|
poster="${item.cover_info.thumbnail}"
|
||||||
|
src="${item.playlist.hd.play_url}"
|
||||||
|
>`;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'link':
|
||||||
|
description += `<div><a href="${item.url}">${item.title}</a><br><img referrerpolicy="no-referrer" src="${item.image_url}" /></div>`;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
description += '未知类型,请点击<a href="https://github.com/DIYgod/RSSHub/issues">链接</a>提交issue';
|
||||||
|
}
|
||||||
|
|
||||||
|
return description;
|
||||||
|
}, `<a href="https://www.zhihu.com${target.author.url}">${author}</a>:`);
|
||||||
|
|
||||||
|
return {
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
author,
|
||||||
|
pubDate,
|
||||||
|
link,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user