From 0449e781dc04de9f9603fee2f3a05bff2631c4bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=89=E5=87=89?= Date: Thu, 18 Oct 2018 14:37:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=EF=BC=9A=E8=B1=86=E7=93=A3?= =?UTF-8?q?=E5=90=8C=E5=9F=8E-=E7=83=AD=E9=97=A8=E6=B4=BB=E5=8A=A8=20(#917?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 部分实现 #911 - 没有选择从[同城首页](https://www.douban.com/location)获取**热门活动**的原因是上面无法获取到活动时间地址等信息,必须到活动详情页才能拿到,都轮一遍感觉消耗有些大,因此选择走接口获取数据。就是获取`locationId`会麻烦些,看后续反馈怎么样吧再做相应调整(逃 --- docs/README.md | 2 ++ router.js | 1 + routes/douban/event/hot.js | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 routes/douban/event/hot.js diff --git a/docs/README.md b/docs/README.md index f4f11c268..c40198dd0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -440,6 +440,8 @@ RSSHub 提供下列 API 接口: + + ### Disqus diff --git a/router.js b/router.js index b72d0d1d7..8130288e5 100644 --- a/router.js +++ b/router.js @@ -190,6 +190,7 @@ router.get('/douban/group/:groupid', require('./routes/douban/group')); router.get('/douban/explore', require('./routes/douban/explore')); router.get('/douban/music/latest', require('./routes/douban/latest_music')); router.get('/douban/book/latest', require('./routes/douban/latest_book')); +router.get('/douban/event/hot/:locationId', require('./routes/douban/event/hot')); // 煎蛋 router.get('/jandan/:sub_model', require('./routes/jandan/pic')); diff --git a/routes/douban/event/hot.js b/routes/douban/event/hot.js new file mode 100644 index 000000000..6e975b89e --- /dev/null +++ b/routes/douban/event/hot.js @@ -0,0 +1,32 @@ +const axios = require('../../../utils/axios'); + +module.exports = async (ctx) => { + const { locationId = 0 } = ctx.params; + const referer = 'https://m.douban.com/app_topic/event_hot'; + + const response = await axios({ + method: 'get', + url: `https://m.douban.com/rexxar/api/v2/subject_collection/event_hot/items?os=ios&for_mobile=1&callback=&start=0&count=20&loc_id=${locationId}`, + headers: { + Referer: referer, + }, + }); + + ctx.state.data = { + title: '豆瓣同城-热门活动', + link: referer, + item: response.data.subject_collection_items.map(({ title, url, date, cover, subtype, info, price_range }) => { + const pubDate = new Date(date).toUTCString(); + const description = `
+ ${info}/${subtype}/${price_range} + `; + + return { + title, + description, + pubDate, + link: url, + }; + }), + }; +};