diff --git a/lib/routes/zhihu/utils.ts b/lib/routes/zhihu/utils.ts index 24a4115fa..3a41e1131 100644 --- a/lib/routes/zhihu/utils.ts +++ b/lib/routes/zhihu/utils.ts @@ -70,8 +70,12 @@ export const getSignedHeader = async (url: string, apiPath: string) => { // fisrt: get cookie(dc_0) from zhihu.com const dc0 = await cache.tryGet('zhihu:cookies:d_c0', async () => { - const response1 = await ofetch.raw(url); - const zseCk = response1._data.match(/var e="__zse_ck",t=\(typeof __g\.ck == 'string' && __g\.ck\)\|\|"([\w+/=]*?)",_=6048e5;/)?.[1]; + if (getCookieValueByKey('d_c0')) { + return getCookieValueByKey('d_c0'); + } + const response1 = await ofetch.raw('https://static.zhihu.com/zse-ck/v3.js'); + const script = await response1._data.text(); + const zseCk = script.match(/__g\.ck\|\|"([\w+/=\\]*?)",_=630e8;/)?.[1]; const response2 = zseCk ? await ofetch.raw(url, {