{"record":{"id":"b6dfaeded1a33af9","repo":"DIYgod/RSSHub","slug":"zhihu-challenge-page-did-not-contain-an-url-to","errorCode":null,"errorMessage":"zhihu: challenge page did not contain an URL to __zse_ck meta/script","messagePattern":"zhihu: challenge page did not contain an URL to __zse_ck meta/script","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/routes/zhihu/utils.ts","lineNumber":129,"sourceCode":"    }\n    if (!dc0) {\n        throw new Error('zhihu: failed to obtain a guest d_c0 cookie');\n    }\n\n    const challenge = await ofetch.raw(`https://www.zhihu.com${apiPath}`, {\n        headers: {\n            ...headers,\n            cookie: `d_c0=${dc0}; __zse_ck=005_x-x`,\n            referer: url,\n            'x-requested-with': 'fetch',\n        },\n        ignoreResponseError: true,\n    });\n    const html = challenge._data as string;\n    const meta = html.match(/id=\"zh-zse-ck\"[^>]*content=\"([^\"]*)\"/)?.[1];\n    const hash = html.match(/zse-ck\\/v4\\/([a-f0-9]+)\\.js/)?.[1];\n    if (!meta || !hash) {\n        throw new Error('zhihu: challenge page did not contain an URL to __zse_ck meta/script');\n    }\n\n    const vmScript = await ofetch<string>(`https://static.zhihu.com/zse-ck/v4/${hash}.js`, {\n        headers,\n        parseResponse: (text) => text,\n    });\n    const dom = new JSDOM(`<!doctype html><html><head><meta id=\"zh-zse-ck\" content=\"${meta}\"><script data-assets-tracker-config='{\"appName\":\"zse_ck\"}'></script></head><body></body></html>`, {\n        url,\n        referrer: 'https://www.zhihu.com/',\n        runScripts: 'outside-only',\n        pretendToBeVisual: true,\n        virtualConsole: new VirtualConsole(),\n    });\n    const { window } = dom;\n    Object.defineProperties(window.navigator, {\n        userAgent: { value: ua, configurable: true },\n        webdriver: { value: false, configurable: true },\n    });","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/zhihu/utils.ts#L111-L147","documentation":"Thrown after the guest `d_c0` is obtained, when the Zhihu challenge page (fetched for the target API path) does not contain the two regex matches the generator expects: a `<meta id=\"zh-zse-ck\" content=\"...\">` value and a `zse-ck/v4/<hash>.js` script URL. Without both, the obfuscated challenge script cannot be located and run, so token generation aborts.","triggerScenarios":"Zhihu changes the structure of its challenge/interstitial page — renames the meta element, changes the script path format, or serves a different anti-bot page (e.g. a slider captcha) that no longer matches the hardcoded regexes.","commonSituations":"Zhihu ships a new version of its `__zse_ck` challenge (new script path scheme, new meta id); the regexes go stale after a frontend redesign; the response is a captcha/ban page instead of the expected challenge HTML. This is a structural break, not transient.","solutions":["Open the challenge page URL in a browser and inspect its HTML to find the new meta element id/attribute and the new script URL pattern, then update the two regexes.","Set `config.zhihu.cookies` with a valid `__zse_ck`/`d_c0` so the in-VM challenge generation is avoided where possible.","If Zhihu replaced the meta/script scheme entirely, rework the extraction logic rather than tweaking the regex."],"exampleFix":"// before\nconst meta = html.match(/id=\"zh-zse-ck\"[^>]*content=\"([^\"]*)\"/)?.[1];\nconst hash = html.match(/zse-ck\\/v4\\/([a-f0-9]+)\\.js/)?.[1];\n// after — updated to match Zhihu's new challenge markup\nconst meta = html.match(/id=\"zh-zse-ck-new\"[^>]*content=\"([^\"]*)\"/)?.[1];\nconst hash = html.match(/zse-ck\\/v5\\/([a-f0-9]+)\\.js/)?.[1];","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Distinguish structural (regex miss) from transient failures and fall back to configured creds\ntry {\n    return await generateZseCk(url, apiPath, configuredDc0);\n} catch (e) {\n    if ((e as Error).message.includes('did not contain an URL')) {\n        logger.error('Zhihu challenge page structure changed — regex needs updating');\n    }\n    if (configuredDc0) return { dc0: configuredDc0 };\n    throw e;\n}","preventionTips":["Monitor for this specific error — it signals a Zhihu anti-bot page redesign that needs a code fix, not a retry.","Keep a known-good snapshot of the challenge page HTML in tests so regex regressions are caught in CI.","Prefer configured credentials to avoid depending on the live challenge page at all."],"tags":["zhihu","anti-bot","regex","api-change","scraping"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}