From 0152cfefde39aa8390bf96f0b1ae2d90badd9552 Mon Sep 17 00:00:00 2001 From: Andvari <31068367+dzx-dzx@users.noreply.github.com> Date: Wed, 10 Jul 2024 20:25:04 +0800 Subject: [PATCH] fix(route/zhihu): Extract `__zse_ck` in a new way. (#16137) * fix(route/zhihu): Extract `__zse_ck` in a new way. * Update utils.ts --- lib/routes/zhihu/utils.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/routes/zhihu/utils.ts b/lib/routes/zhihu/utils.ts index 5011e57dba4e2e..2e54aabd2022c0 100644 --- a/lib/routes/zhihu/utils.ts +++ b/lib/routes/zhihu/utils.ts @@ -63,10 +63,7 @@ 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 $ = load(response1._data); - const zseCk = $('script:contains("__zse_ck")') - .text() - .match(/\|\|"(.*?)",.*;document\.cookie/)?.[1]; + const zseCk = response1._data.match(/var e="__zse_ck",t=\(typeof __g\.ck == 'string' && __g\.ck\)\|\|"([\w+/=]*?)",_=6048e5;/)[1]; const response2 = zseCk ? await ofetch.raw(url, {