Skip to content

feat: add get-notifications command#46

Open
SZhangCoding wants to merge 1 commit intoautoclaw-cc:mainfrom
SZhangCoding:feat/get-notifications
Open

feat: add get-notifications command#46
SZhangCoding wants to merge 1 commit intoautoclaw-cc:mainfrom
SZhangCoding:feat/get-notifications

Conversation

@SZhangCoding
Copy link
Copy Markdown

Summary

  • New CLI command get-notifications to read comment/reply notifications from xiaohongshu.com/notification
  • New module scripts/xhs/notifications.py with typed dataclasses following existing project conventions

How it works

Navigates to the notification page and reads from window.__INITIAL_STATE__.notification.notificationMap.mentions (Vue store), instead of calling the API directly — the mentions API requires dynamic x-s/x-t security headers that cannot be reproduced via plain XHR.

Usage

# Get latest 20 notifications (default)
python scripts/cli.py get-notifications

# Get latest 5
python scripts/cli.py get-notifications --num 5

Response fields

Each notification item includes:

  • type: comment/item (commented on your note) or comment/comment (replied to your comment)
  • content: comment text
  • quotedComment: original comment being replied to (reply type only)
  • user: { userId, nickname, avatar }
  • noteId + noteXsecToken: can be passed directly to reply-comment
  • hasMore + cursor: pagination awareness

🤖 Generated with Claude Code

New command: `cli.py get-notifications [--num N]`

- Navigates to xiaohongshu.com/notification and reads the Vue store
  (window.__INITIAL_STATE__.notification.notificationMap.mentions)
  instead of calling the API directly, which requires dynamic x-s/x-t
  security headers that cannot be replicated via plain XHR.
- Returns structured JSON with per-notification fields:
  - commentId, content, quotedComment (for replies)
  - user info (userId, nickname, avatar, xsecToken)
  - noteId + noteXsecToken (usable directly with reply-comment)
  - hasMore + cursor for pagination awareness
- --num limits returned items (default 20; page loads max 20 per batch)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants