Skip to content

Commit

Permalink
feat(route): 优化微博博主路由 (#14365)
Browse files Browse the repository at this point in the history
  • Loading branch information
CaoMeiYouRen authored Feb 1, 2024
1 parent a123705 commit 002302f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/v2/weibo/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module.exports = async (ctx) => {
displayComments = fallback(undefined, queryToBoolean(routeParams.displayComments), false) ? '1' : '0';
}
}

const containerData = await ctx.cache.tryGet(
`weibo:user:index:${uid}`,
async () => {
Expand All @@ -32,13 +31,15 @@ module.exports = async (ctx) => {
Referer: `https://m.weibo.cn/u/${uid}`,
'MWeibo-Pwa': 1,
'X-Requested-With': 'XMLHttpRequest',
Cookie: config.weibo.cookies,
},
});
return _r.data;
},
config.cache.routeExpire,
false
);

const name = containerData.data.userInfo.screen_name;
const description = containerData.data.userInfo.description;
const profileImageUrl = containerData.data.userInfo.profile_image_url;
Expand All @@ -54,6 +55,7 @@ module.exports = async (ctx) => {
Referer: `https://m.weibo.cn/u/${uid}`,
'MWeibo-Pwa': 1,
'X-Requested-With': 'XMLHttpRequest',
Cookie: config.weibo.cookies,
},
});
return _r.data.data.cards;
Expand Down
10 changes: 8 additions & 2 deletions website/docs/routes/social-media.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1479,8 +1479,14 @@ YouTube provides official RSS feeds for channels, for instance [https://www.yout

### 博主 {#wei-bo-bo-zhu}

<Route author="DIYgod iplusx Rongronggg9" example="/weibo/user/1195230310" path="/weibo/user/:uid/:routeParams?" paramsDesc={['用户 id, 博主主页打开控制台执行 `$CONFIG.oid` 获取', '额外参数;请参阅上面的说明和表格;特别地,当 `routeParams=1` 时开启微博视频显示']} radar="1">
部分博主仅登录可见,不支持订阅,可以通过打开 `https://m.weibo.cn/u/:uid` 验证
<Route author="DIYgod iplusx Rongronggg9" example="/weibo/user/1195230310" path="/weibo/user/:uid/:routeParams?" paramsDesc={['用户 id, 博主主页打开控制台执行 `$CONFIG.oid` 获取', '额外参数;请参阅上面的说明和表格;特别地,当 `routeParams=1` 时开启微博视频显示']} radar="1" anticrawler="1">
:::warning
部分博主仅登录可见,未提供 Cookie 的情况下不支持订阅,可以通过打开 `https://m.weibo.cn/u/:uid` 验证。如需要订阅该部分博主,可配置 Cookie 后订阅。

未提供 Cookie 的情况下偶尔会触发反爬限制,提供 Cookie 可缓解该情况。

微博用户 Cookie 的配置可参照部署文档
:::
</Route>

### 关键词 {#wei-bo-guan-jian-ci}
Expand Down

0 comments on commit 002302f

Please sign in to comment.