Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,16 @@ metadata:

### xhs-explore — 内容发现

搜索笔记、查看详情、获取用户资料。
搜索笔记、查看详情、获取用户资料、管理个人笔记

| 命令 | 功能 |
|------|------|
| `cli.py list-feeds` | 获取首页推荐 Feed |
| `cli.py search-feeds` | 关键词搜索笔记 |
| `cli.py get-feed-detail` | 获取笔记完整内容和评论 |
| `cli.py user-profile` | 获取用户主页信息 |
| `cli.py list-notes` | 获取个人笔记列表(含点赞、收藏、评论数) |
| `cli.py delete-note --note-id <ID>` | 删除指定笔记 |

### xhs-interact — 社交互动

Expand All @@ -104,35 +106,41 @@ metadata:

```bash
# 1. 启动 Chrome
python scripts/chrome_launcher.py
uv run scripts/chrome_launcher.py

# 2. 检查登录状态
python scripts/cli.py check-login
uv run scripts/cli.py check-login

# 3. 登录(如需要)
python scripts/cli.py login
uv run scripts/cli.py login

# 4. 搜索笔记
python scripts/cli.py search-feeds --keyword "关键词"
uv run scripts/cli.py search-feeds --keyword "关键词"

# 5. 查看笔记详情
python scripts/cli.py get-feed-detail \
uv run scripts/cli.py get-feed-detail \
--feed-id FEED_ID --xsec-token XSEC_TOKEN

# 6. 发布图文
python scripts/cli.py publish \
# 6. 获取个人笔记列表
uv run scripts/cli.py list-notes

# 7. 删除个人笔记
uv run scripts/cli.py delete-note --note-id "69b054990000000008032e39"

# 8. 发布图文
uv run scripts/cli.py publish \
--title-file title.txt \
--content-file content.txt \
--images "/abs/path/pic1.jpg"

# 7. 发表评论
python scripts/cli.py post-comment \
# 9. 发表评论
uv run scripts/cli.py post-comment \
--feed-id FEED_ID \
--xsec-token XSEC_TOKEN \
--content "评论内容"

# 8. 点赞
python scripts/cli.py like-feed \
# 10. 点赞
uv run scripts/cli.py like-feed \
--feed-id FEED_ID --xsec-token XSEC_TOKEN
```

Expand Down
52 changes: 52 additions & 0 deletions scripts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,42 @@ def cmd_user_profile(args: argparse.Namespace) -> None:
browser.close()


def cmd_list_notes(args: argparse.Namespace) -> None:
"""获取个人笔记列表。"""
from xhs.node_manager import list_notes

browser, page = _connect(args)
try:
result = list_notes(
page,
note_type=args.note_type or "",
status=args.status or "",
keyword=args.keyword or "",
)
_output(result.to_dict())
finally:
browser.close_page(page)
browser.close()


def cmd_get_note_detail(args: argparse.Namespace) -> None:
"""获取笔记详情(已移除,请使用 list-notes 查看笔记列表)。"""
_output({"success": False, "error": "get-note-detail 命令已移除,请使用 list-notes 查看笔记列表"})


def cmd_delete_note(args: argparse.Namespace) -> None:
"""删除笔记。"""
from xhs.node_manager import delete_note

browser, page = _connect(args)
try:
result = delete_note(page, args.note_id)
_output(result.to_dict())
finally:
browser.close_page(page)
browser.close()


def cmd_post_comment(args: argparse.Namespace) -> None:
"""发表评论。"""
from xhs.comment import post_comment
Expand Down Expand Up @@ -1123,6 +1159,22 @@ def build_parser() -> argparse.ArgumentParser:
sub.add_argument("--xsec-token", required=True, help="xsec_token")
sub.set_defaults(func=cmd_user_profile)

# list-notes(个人笔记列表)
sub = subparsers.add_parser("list-notes", help="获取个人笔记列表")
sub.add_argument("--note-type", help="类型:不限|视频|图文")
sub.add_argument("--status", help="状态:不限|已发布|草稿|待审核|仅自己可见")
sub.add_argument("--keyword", help="关键词筛选")
sub.set_defaults(func=cmd_list_notes)

# get-note-detail(个人笔记详情)
sub = subparsers.add_parser("get-note-detail", help="获取笔记详情(已移除)")
sub.set_defaults(func=cmd_get_note_detail)

# delete-note(删除笔记)
sub = subparsers.add_parser("delete-note", help="删除笔记")
sub.add_argument("--note-id", required=True, help="笔记 ID")
sub.set_defaults(func=cmd_delete_note)

# post-comment
sub = subparsers.add_parser("post-comment", help="发表评论")
sub.add_argument("--feed-id", required=True, help="Feed ID")
Expand Down
Loading