Skip to content

[Feature] Support rednote.com (international mirror) in xiaohongshu adapter #1136

@AlanSmith111

Description

@AlanSmith111

Problem

International Xiaohongshu accounts now land on rednote.com instead of www.xiaohongshu.com — the site 302-redirects non-mainland users to the rednote domain. As a result, every opencli xiaohongshu * subcommand fails with AUTH_REQUIRED, because the adapter is hardcoded to www.xiaohongshu.com and cookies live under a different root domain.

Users in this situation are fully logged in on rednote.com but have no way to reach the adapter.

Investigation

Spent some time comparing the two frontends via opencli browser. The short version: rednote.com is the same codebase with a different domain — backend APIs mirror xiaohongshu.com 1:1.

Identical

  • DOM selectors used by the adapter: section.note-item, a.cover, #search-input, #detail-desc, #detail-title, .note-content, .username, .comment-item, .comment-item .content
  • URL paths: /search_result?keyword=..., /search_result/{id}?xsec_token=..., /explore/{id}?xsec_token=...
  • API paths: /api/sns/web/v1/search/notes, /api/sns/web/v2/user/me, /api/sns/web/unread_count, /api/sns/web/v1/search/filter, …
  • Response schema (data.items[].note_card.*, xsec_token, etc.)
  • Core cookies: a1, xsecappid, webId
  • xsec_token auth mechanism

Different (only the hostnames)

xiaohongshu rednote
Web host www.xiaohongshu.com www.rednote.com
API host edith.xiaohongshu.com webapi.rednote.com
Security/signing host fe-static.xhscdn.com as.rednote.com
Cookie root .xiaohongshu.com .rednote.com
Login gate 登录后查看搜索结果 inline text Full-screen login modal
web_session cookie present absent (different session mechanism; still authenticates)

Possible directions

Listing options — happy to go with whichever the maintainers prefer:

  1. Domain routing inside the existing xiaohongshu adapter — pick host pair based on cookie presence or an env flag. Minimal new code, but touches currently-stabilizing xhs files.
  2. Separate clis/rednote/ adapter — zero impact on xhs, at the cost of near-duplicate code for selectors/API paths.
  3. Extract _shared/xhs-core and have both xiaohongshu and rednote adapters declare only their domain triple. Cleanest but largest refactor.

My lean is (2) for safety given the active xhs bugfix traffic in the last few weeks (#980, #996, #1050, #1060), but I don't want to block on that — happy to follow whichever direction you'd like.

Notes

  • Also need to handle the login-gate detection change (modal instead of inline text) for the WAIT_FOR_CONTENT_JS branch in search.js.
  • download.js uses page.getCookies({ domain: 'xiaohongshu.com' }); rednote flow would need 'rednote.com'.
  • creator.xiaohongshu.com (publish / creator-*) may not have a rednote counterpart; those can be left xhs-only initially.

Willing to submit the PR once you pick a direction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions