{"record":{"id":"72b70bd8ebcbbeb6","repo":"jackwener/OpenCLI","slug":"www-rednote-com-72b70b","errorCode":null,"errorMessage":"www.rednote.com","messagePattern":"www\\.rednote\\.com","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/rednote/search.js","lineNumber":91,"sourceCode":"    site: 'rednote',\n    name: 'search',\n    access: 'read',\n    description: 'Search rednote notes',\n    domain: 'www.rednote.com',\n    strategy: Strategy.COOKIE,\n    navigateBefore: false,\n    args: [\n        { name: 'query', required: true, positional: true, help: 'Search keyword' },\n        { name: 'limit', type: 'int', default: 20, help: 'Number of results' },\n    ],\n    columns: ['rank', 'title', 'author', 'likes', 'published_at', 'url', 'author_url'],\n    func: async (page, kwargs) => {\n        const limit = parseLimit(kwargs.limit ?? 20);\n        const keyword = encodeURIComponent(kwargs.query);\n        await page.goto(`https://www.rednote.com/search_result?keyword=${keyword}&source=web_search_result_notes`);\n        const waitResult = unwrapEvaluateResult(await page.evaluate(WAIT_FOR_CONTENT_JS));\n        if (waitResult === 'login_wall') {\n            throw new AuthRequiredError('www.rednote.com', 'Rednote search results are blocked behind a login wall');\n        }\n        // Scroll until enough rows are rendered or the lazy-load plateaus.\n        // Same fix as xiaohongshu/search (#1471): the previous fixed\n        // `autoScroll({ times: 2 })` capped extraction at ~13 notes regardless\n        // of `--limit`.\n        await page.evaluate(buildScrollUntilJs(limit));\n        const data = requireSearchRows(await page.evaluate(buildSearchExtractJs('www.rednote.com')));\n        return data\n            .filter((item) => item.title)\n            .slice(0, limit)\n            .map((item, i) => ({\n            rank: i + 1,\n            ...item,\n            published_at: noteIdToDate(item.url),\n        }));\n    },\n});\n","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/rednote/search.js#L73-L109","documentation":"AuthRequiredError is thrown when the rednote search results page is served behind a login wall instead of public results. The library detects this in-page (WAIT_FOR_CONTENT_JS returns 'login_wall') and raises with host 'www.rednote.com' and guidance that authentication is required.","triggerScenarios":"page.evaluate(WAIT_FOR_CONTENT_JS) resolving to 'login_wall' after navigating to https://www.rednote.com/search_result?keyword=...&source=web_search_result_notes — rednote demands a logged-in session before showing search results.","commonSituations":"Fresh browser profiles with no rednote cookies, expired sessions, running from datacenter IPs that rednote forces to log in, or anonymous/incognito automation contexts.","solutions":["Log in to www.rednote.com in the automation browser profile so a session cookie exists","Re-authenticate if the stored session expired, then rerun the command","Use a residential/session-persistent browser context rather than a fresh incognito profile","Retry later if rednote is aggressively gating your IP; consider a different network"],"exampleFix":"// before\nawait page.goto(searchUrl); // anonymous profile -> login wall\n// after\nif (!await hasSession(page)) await loginToRednote(page); // establish cookies first\nawait page.goto(searchUrl);","handlingStrategy":"try-catch","validationCode":"const state = unwrapEvaluateResult(await page.evaluate(WAIT_FOR_CONTENT_JS)); if (state === 'login_wall') throw new Error('authenticate www.rednote.com before searching');","typeGuard":"const isLoginWall = (state) => state === 'login_wall';","tryCatchPattern":"try { return await rednoteSearch(query, limit); } catch (e) { if (e instanceof AuthRequiredError && e.host === 'www.rednote.com') { await loginToRednote(page); return rednoteSearch(query, limit); } throw e; }","preventionTips":["Keep a logged-in rednote session in the automation browser profile","Handle AuthRequiredError explicitly by triggering re-auth then retrying once","Avoid fresh incognito/datacenter contexts that rednote gates behind login"],"tags":["authentication","login-wall","browser-automation"],"backgroundTag":"auth-required-login-wall","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}