fix(route): zhihu private answers (#12379)
* fix(route): zhihu answers * fix: more robust caching
This commit is contained in:
parent
b088a9875a
commit
75fc439daf
|
|
@ -19,16 +19,20 @@ module.exports = async (ctx) => {
|
|||
let name = data[0].author.name;
|
||||
|
||||
if (name === '知乎用户') {
|
||||
const info = await got({
|
||||
method: 'get',
|
||||
url: `https://www.zhihu.com/api/v4/members/${id}/activities?limit=1`,
|
||||
headers: {
|
||||
...utils.header,
|
||||
Referer: `https://www.zhihu.com/people/${id}/activities`,
|
||||
Authorization: 'oauth c3cef7c66a1843f8b3a9e6a1e3160e20', // hard-coded in js
|
||||
},
|
||||
const userProfile = await ctx.cache.tryGet(`zhihu:profile:${id}`, async () => {
|
||||
const apiPath = `/api/v4/profile/${id}/infinity`;
|
||||
|
||||
const { data } = await got({
|
||||
method: 'get',
|
||||
url: `https://www.zhihu.com${apiPath}`,
|
||||
headers: {
|
||||
...utils.header,
|
||||
Referer: `https://www.zhihu.com/people/${id}`,
|
||||
},
|
||||
});
|
||||
return data.data;
|
||||
});
|
||||
name = info.data.data[0].actor.name;
|
||||
name = userProfile.name;
|
||||
}
|
||||
|
||||
const items = await Promise.all(
|
||||
|
|
|
|||
Loading…
Reference in New Issue