feat: add bilibili/comments, xiaohongshu/comments commands + rate-limiter plugin docs#457
Conversation
…lugin docs - bilibili/comments: fetch top-level replies via /x/v2/reply/main with WBI signing (bvid → aid resolution + signed params, no DOM dependency) - xiaohongshu/comments: DOM extraction from note detail page with login-wall detection and correct handling of 0-like counts (XHS shows "赞" text instead of "0") - docs/advanced/rate-limiter-plugin.md: documents the onAfterExecute hook pattern and shows a plug-and-play rate limiter that adds random sleep between platform commands to reduce bot-detection risk Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Both comments commands follow existing patterns nicely: bilibili reuses WBI signing, xiaohongshu goes with DOM extraction. A few things I noticed: bilibili/comments error handling The bvid resolution failure throws a bare xiaohongshu/comments can't consume search output
Output field leak Each comment object includes Empty result semantics xiaohongshu throws |
Summary
bilibili/comments <bvid>— fetches top-level replies via/x/v2/reply/mainwith WBI signing. Resolves bvid → aid via/x/web-interface/view, then calls the reply API withsigned: true. No DOM dependency, same pattern asbilibili/search.xiaohongshu/comments <note-id>— DOM extraction from the note detail page (/explore/<id>). XHS doesn't expose a public comments API, so we scroll the note container and scrape.parent-commentelements. Handles two edge cases:AuthRequiredError).countelement when likes = 0; the extractor converts that to0instead of a string.docs/advanced/rate-limiter-plugin.md— documents theonAfterExecutehook and shows a copy-paste rate-limiter plugin that adds a random 5–30 s sleep after every browser-platform command. Useful for long-running scraping jobs. Controlled viaOPENCLI_RATE_MIN,OPENCLI_RATE_MAX, andOPENCLI_NO_RATE=1(disable for local dev).Test plan
npm test— all 294 existing tests pass; 10 new tests added (5 per command)npx tsc --noEmit— no type errorsopencli bilibili comments BV1WtAGzYEBm --limit 5returns ranked comment rowsopencli xiaohongshu comments <note-id> --limit 5returns comment rows when logged in[rate-limiter] xiaohongshu: sleeping Xsto stderr🤖 Generated with Claude Code