Skip to content

Commit

Permalink
fix(route/zhihu): Fix d_c0 (DIYgod#16691)
Browse files Browse the repository at this point in the history
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
  • Loading branch information
dzx-dzx and TonyRL authored Sep 11, 2024
1 parent 7a7309c commit d8b7aae
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/routes/zhihu/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit d8b7aae

Please sign in to comment.