-
Notifications
You must be signed in to change notification settings - Fork 714
Open
Description
Bug: Xiaohongshu comments command returns empty due to anti-automation detection
Description
The opencli xiaohongshu comments command always returns empty results because Xiaohongshu (小红书) detects browser automation and redirects to an error page.
Environment
- opencli version: 1.5.3
- Node version: 22.22.1
- Browser Bridge: Connected (v1.5.3)
- OS: macOS (Darwin 24.6.0)
Steps to Reproduce
- Ensure Chrome is running and logged into www.xiaohongshu.com
- Run:
opencli xiaohongshu comments <note-id> - Command returns empty array
Investigation Results
I added debug logging to the comments.ts source code and discovered:
1. Page Redirection
- Target URL:
https://www.xiaohongshu.com/explore/{noteId} - Actual URL:
https://www.xiaohongshu.com/explore(redirected to homepage)
When using /search_result/{noteId}:
- Target URL:
https://www.xiaohongshu.com/search_result/{noteId} - Actual URL:
https://www.xiaohongshu.com/website-login/error?error_code=300017&error_msg=访问链接异常
2. Error Page Content
安全限制
访问链接异常
300017
3. What Works vs What Doesn't
| Endpoint | Status |
|---|---|
/search_result?keyword=xxx (search) |
✅ Works |
/explore/{noteId} (note detail) |
❌ Redirected |
/search_result/{noteId} (note detail) |
❌ Error page |
4. Authentication Status
- Cookie count: 12 cookies present
- Login state: Valid (search works, no login button visible)
- Browser Bridge: Connected successfully
Root Cause
Xiaohongshu has anti-automation detection on note detail pages:
- Search pages (
/search_result?keyword=) are accessible - Note detail pages trigger security check (error code 300017)
- The Browser Bridge's automation signature is being detected
Related Commands Affected
xiaohongshu comments- Cannot access note detail pagexiaohongshu download- Also returns "No media found" for the same reason
Possible Solutions
- Stealth mode: Implement anti-detection measures (similar to puppeteer-extra-plugin-stealth)
- Alternative endpoints: Explore if there are API endpoints that don't trigger detection
- User interaction flow: Guide users to manually open the note page first, then extract from existing tab
Debug Code Used
I modified comments.ts to capture page state:
const data = await page.evaluate(`
(async () => {
// ... existing scroll logic ...
return {
loginWall: /登录后查看|请登录/.test(document.body.innerText || ''),
pageInfo: {
title: document.title,
url: location.href,
bodyTextSample: document.body.innerText.slice(0, 500),
cookieCount: document.cookie.split(';').length
},
results: []
};
})()
`);Results showed redirect to homepage with only footer content visible.
Workaround
Currently no workaround available. Users must manually view comments in browser.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels