fix(route/zhihu): Allow to set __zse_ck in signedHeader (#18774)

This commit is contained in:
Andvari
2025-04-05 01:14:45 +08:00
committed by GitHub
parent 6290710c93
commit aa38e959e7
+5 -5
View File
@@ -69,9 +69,9 @@ export const getSignedHeader = async (url: string, apiPath: string) => {
// require users to set the cookie in environmental variables anymore.
// fisrt: get cookie(dc_0) from zhihu.com
const dc0 = await cache.tryGet('zhihu:cookies:d_c0', async () => {
if (getCookieValueByKey('d_c0')) {
return getCookieValueByKey('d_c0');
const { dc0, zseCk } = await cache.tryGet('zhihu:cookies:d_c0', async () => {
if (getCookieValueByKey('d_c0') && getCookieValueByKey('__zse_ck')) {
return { dc0: getCookieValueByKey('d_c0'), zseCk: getCookieValueByKey('__zse_ck') };
}
const response1 = await ofetch.raw('https://static.zhihu.com/zse-ck/v3.js');
const script = await response1._data.text();
@@ -95,7 +95,7 @@ export const getSignedHeader = async (url: string, apiPath: string) => {
.trim()
.slice('d_c0='.length) || '';
return dc0;
return { dc0, zseCk };
});
// calculate x-zse-96, refer to https://github.com/srx-2000/spider_collection/issues/18
@@ -106,7 +106,7 @@ export const getSignedHeader = async (url: string, apiPath: string) => {
const zc0 = getCookieValueByKey('z_c0');
return {
cookie: `d_c0=${dc0}${zc0 ? `;z_c0=${zc0}` : ''}`,
cookie: `__zse_ck=${zseCk}; d_c0=${dc0}${zc0 ? `;z_c0=${zc0}` : ''}`,
'x-zse-96': xzse96,
'x-app-za': 'OS=Web',
'x-zse-93': xzse93,