fix(route/zhihu): Fix d_c0 (#16691)

Co-authored-by: Tony <TonyRL@users.noreply.github.com>
This commit is contained in:
Andvari
2024-09-11 23:33:16 +08:00
committed by GitHub
co-authored by Tony
parent 7a7309ca1e
commit d8b7aae47a
+6 -2
View File
@@ -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, {