{"record":{"id":"0a83f29a22008855","repo":"jackwener/OpenCLI","slug":"security-block-0a83f2","errorCode":"SECURITY_BLOCK","errorMessage":"Xiaohongshu security block: the note detail page was blocked by risk control.","messagePattern":"Xiaohongshu security block: the note detail page was blocked by risk control\\.","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/note.js","lineNumber":87,"sourceCode":"    domain: 'www.xiaohongshu.com',\n    strategy: Strategy.COOKIE,\n    navigateBefore: false,\n    args: [\n        { name: 'note-id', required: true, positional: true, help: 'Full Xiaohongshu note URL with xsec_token' },\n    ],\n    columns: ['field', 'value'],\n    func: async (page, kwargs) => {\n        const raw = String(kwargs['note-id']);\n        const noteId = parseNoteId(raw);\n        const url = buildNoteUrl(raw, { commandName: 'xiaohongshu note' });\n        await page.goto(url);\n        await page.wait({ time: 2 + Math.random() * 3 });\n        const data = await page.evaluate(NOTE_EXTRACT_JS);\n        if (!data || typeof data !== 'object') {\n            throw new EmptyResultError('xiaohongshu/note', 'Unexpected evaluate response');\n        }\n        if (data.securityBlock) {\n            throw new CliError('SECURITY_BLOCK', 'Xiaohongshu security block: the note detail page was blocked by risk control.', /^https?:\\/\\//.test(raw)\n                ? 'The page may be temporarily restricted. Try again later or from a different session.'\n                : 'Try using a full URL from search results (with xsec_token) instead of a bare note ID.');\n        }\n        if (data.loginWall) {\n            throw new AuthRequiredError('www.xiaohongshu.com', 'Note content requires login');\n        }\n        if (data.notFound) {\n            throw new EmptyResultError('xiaohongshu/note', `Note ${noteId} not found or unavailable — it may have been deleted or restricted`);\n        }\n        const d = data;\n        // XHS renders placeholder text like \"赞\"/\"收藏\"/\"评论\" when count is 0;\n        // normalize to '0' unless the value looks numeric.\n        const numOrZero = (v) => /^\\d+/.test(v) ? v : '0';\n        // A note may legitimately have no title, but a real note page always\n        // renders an author. If both are missing, the page failed to load.\n        if (!d.title && !d.author) {\n            throw new EmptyResultError('xiaohongshu/note', 'The note page loaded without visible content. The note may be deleted or restricted.');\n        }","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/note.js#L69-L105","documentation":"The in-page extraction script flagged data.securityBlock, meaning Xiaohongshu risk control blocked the note detail page (captcha or verification wall). The command throws CliError with code SECURITY_BLOCK and a hint that differs depending on whether the input was a URL or a bare ID.","triggerScenarios":"page.evaluate(NOTE_EXTRACT_JS) returns { securityBlock: true } — XHS served a risk-control/verification page instead of note content.","commonSituations":"Too many automated requests from one session/IP; using bare note IDs which look suspicious to risk control; datacenter IP or unfamiliar browser fingerprint; expired xsec_token triggering verification.","solutions":["Wait and retry later — blocks are usually temporary.","Switch to a full URL with a valid xsec_token from search results instead of a bare note ID.","Use a different Chrome session/profile or network to change the fingerprint.","Reduce request frequency and complete any captcha manually in the browser."],"exampleFix":"// before\nawait note('65a1b2c3'); // bare ID, high risk-control score\n// after\nawait note('https://www.xiaohongshu.com/explore/65a1b2c3?xsec_token=<fresh-token>');","handlingStrategy":"try-catch","validationCode":"// Prefer full signed URLs over bare IDs to lower risk-control score\nif (!/^https?:\\/\\//.test(raw)) console.warn('bare note ID increases security-block risk');","typeGuard":"function isSecurityBlockError(err) {\n  return err instanceof CliError && err.code === 'SECURITY_BLOCK';\n}","tryCatchPattern":"try {\n  await note(raw);\n} catch (err) {\n  if (isSecurityBlockError(err)) {\n    await sleep(60_000); // back off, then retry with a fresh signed URL\n    return note(freshSignedUrl);\n  } else throw err;\n}","preventionTips":["Always use full URLs with xsec_token instead of bare note IDs.","Throttle request rate; avoid rapid successive automation calls.","Complete any captcha manually in the browser session when it appears.","Rotate sessions/networks if blocks recur."],"tags":["xiaohongshu","risk-control","security-block"],"backgroundTag":"anti-bot-block-detected","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}