diff --git a/lib/routes/weibo/user.js b/lib/routes/weibo/user.js index 76b932ee8..587df0d96 100644 --- a/lib/routes/weibo/user.js +++ b/lib/routes/weibo/user.js @@ -23,13 +23,15 @@ module.exports = async (ctx) => { } const containerData = await ctx.cache.tryGet( - `weibo:user:profile:${uid}`, + `weibo:user:index:${uid}`, async () => { const _r = await got({ method: 'get', - url: `https://m.weibo.cn/profile/info?uid=${uid}`, + url: `https://m.weibo.cn/api/container/getIndex?type=uid&value=${uid}`, headers: { - Referer: 'https://m.weibo.cn/', + Referer: `https://m.weibo.cn/u/${uid}`, + 'MWeibo-Pwa': 1, + 'X-Requested-With': 'XMLHttpRequest', }, }); return _r.data; @@ -37,17 +39,17 @@ module.exports = async (ctx) => { config.cache.routeExpire, false ); - const name = containerData.data.user.screen_name; - const description = containerData.data.user.description; - const profileImageUrl = containerData.data.user.profile_image_url; - const containerId = containerData.data.more.match(/\d+/)[0]; + const name = containerData.data.userInfo.screen_name; + const description = containerData.data.userInfo.description; + const profileImageUrl = containerData.data.userInfo.profile_image_url; + const containerId = containerData.data.tabsInfo.tabs.filter((item) => item.tab_type === 'weibo')[0].containerid; const cards = await ctx.cache.tryGet( `weibo:user:cards:${uid}:${containerId}`, async () => { const _r = await got({ method: 'get', - url: `https://m.weibo.cn/api/container/getIndex?containerid=${containerId}`, + url: `https://m.weibo.cn/api/container/getIndex?type=uid&value=${uid}&containerid=${containerId}`, headers: { Referer: `https://m.weibo.cn/u/${uid}`, 'MWeibo-Pwa': 1,