From 84ea794d8fa9c87ec88efa473d231a98e2c0f4cd Mon Sep 17 00:00:00 2001 From: zengxs Date: Sun, 28 Apr 2019 11:44:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E5=BE=AE=E5=8D=9A=E8=B6=85=E8=AF=9D=20(#2007)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/social-media.md | 2 ++ lib/router.js | 1 + lib/routes/weibo/super_index.js | 49 +++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 lib/routes/weibo/super_index.js diff --git a/docs/social-media.md b/docs/social-media.md index c7ad54eff..76063020c 100644 --- a/docs/social-media.md +++ b/docs/social-media.md @@ -180,6 +180,8 @@ + + ## 贴吧 diff --git a/lib/router.js b/lib/router.js index 03d7a8b28..74b0764d7 100755 --- a/lib/router.js +++ b/lib/router.js @@ -134,6 +134,7 @@ router.get('/weibo/user/:uid', require('./routes/weibo/user')); router.get('/weibo/user2/:uid', require('./routes/weibo/user2')); router.get('/weibo/keyword/:keyword', require('./routes/weibo/keyword')); router.get('/weibo/search/hot', require('./routes/weibo/search/hot')); +router.get('/weibo/super_index/:id', require('./routes/weibo/super_index')); // 贴吧 router.get('/tieba/forum/:kw', require('./routes/tieba/forum')); diff --git a/lib/routes/weibo/super_index.js b/lib/routes/weibo/super_index.js new file mode 100644 index 000000000..5f489c446 --- /dev/null +++ b/lib/routes/weibo/super_index.js @@ -0,0 +1,49 @@ +const axios = require('../../utils/axios'); +const weiboUtils = require('./utils'); +const date = require('../../utils/date'); + +module.exports = async (ctx) => { + const id = ctx.params.id; + + const res = await axios.get('https://m.weibo.cn/api/container/getIndex', { + params: { + containerid: `${id}_-_feed`, + luicode: '10000011', + lfid: `${id}_-_main`, + }, + headers: { + Referer: `https://m.weibo.cn/p/index?containerid=${id}_-_soul&luicode=10000011&lfid=${id}_-_main`, + 'MWeibo-Pwa': '1', + 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1', + 'X-Requested-With': 'XMLHttpRequest', + }, + }); + + const resultItems = []; + + for (const card of res.data.data.cards) { + if (!('card_group' in card)) { + continue; + } + for (const mblogCard of card.card_group) { + if (mblogCard.card_type === '9' && 'mblog' in mblogCard) { + const mblog = mblogCard.mblog; + const desc = weiboUtils.format(mblog); + resultItems.push({ + title: desc.replace(//g, '[图片]').replace(/<.*?>/g, ''), + description: desc, + author: mblog.user.screen_name, + link: `https://weibo.com/${mblog.user.id}/${mblog.bid}`, + pubDate: date(mblog.created_at, 8), + }); + } + } + } + + ctx.state.data = { + title: `微博超话 - ${res.data.data.pageInfo.page_title}`, + link: `https://weibo.com/p/${id}/super_index`, + description: `#${res.data.data.pageInfo.page_title}# 的超话`, + item: resultItems, + }; +};