fix(route)(weibo/user): outdated API method (#9446)

Signed-off-by: Rongrong <15956627+Rongronggg9@users.noreply.github.com>
This commit is contained in:
Rongrong
2022-04-02 17:20:19 +08:00
committed by GitHub
parent 92997224aa
commit 63b3b044cd
+10 -8
View File
@@ -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,