增加:豆瓣热门图书排行 (#1016)

This commit is contained in:
凉凉
2018-10-31 11:14:57 +08:00
committed by DIYgod
parent 94b0f45a8a
commit 88b58bd4bf
3 changed files with 40 additions and 0 deletions
+8
View File
@@ -468,6 +468,14 @@ RSSHub 提供下列 API 接口:
<route name="豆瓣书店" author="xyqfer" example="/douban/bookstore" path="/douban/bookstore"/>
<route name="热门图书排行" author="xyqfer" example="/douban/book/rank/fiction" path="/douban/book/rank/:type" :paramsDesc="['图书类型']">
| 虚构 | 非虚构 |
| ------- | ---------- |
| fiction | nonfiction |
</route>
### Disqus
<route name="评论" author="DIYgod" example="/disqus/posts/diygod-me" path="/disqus/posts/:forum" :paramsDesc="['网站的 disqus name']"/>
+1
View File
@@ -196,6 +196,7 @@ router.get('/douban/book/latest', require('./routes/douban/latest_book'));
router.get('/douban/event/hot/:locationId', require('./routes/douban/event/hot'));
router.get('/douban/commercialpress/latest', require('./routes/douban/commercialpress/latest'));
router.get('/douban/bookstore', require('./routes/douban/bookstore'));
router.get('/douban/book/rank/:type', require('./routes/douban/book/rank'));
// 煎蛋
router.get('/jandan/:sub_model', require('./routes/jandan/pic'));
+31
View File
@@ -0,0 +1,31 @@
const axios = require('../../../utils/axios');
module.exports = async (ctx) => {
const { type = 'fiction' } = ctx.params;
const referer = `https://m.douban.com/subject_collection/book_${type}_hot_weekly`;
const response = await axios({
method: 'get',
url: `https://m.douban.com/rexxar/api/v2/subject_collection/book_${type}_hot_weekly/items?start=0&count=10`,
headers: {
Referer: referer,
},
});
ctx.state.data = {
title: `豆瓣热门图书-${type === 'fiction' ? '虚构类' : '非虚构类'}`,
link: referer,
description: '每周一更新',
item: response.data.subject_collection_items.map(({ title, url, cover, info, rating }) => {
const description = `<img referrerpolicy="no-referrer" src="${cover.url}"><br>
${title}/${info}/${rating.value.toFixed(1)}分
`;
return {
title: `${title}-${info}`,
description,
link: url,
};
}),
};
};