JW

jackwener/weibo-cli

Developer tools
86ย stars ํ’ˆ์งˆ 70 ํŠธ๋ Œ๋“œ 70

A CLI for Weibo (ๅพฎๅš) โ€” search, browse hot topics, read timelines, and explore user profiles from the terminal ๐Ÿฆ

๊ฐœ์š”

A CLI for Weibo (ๅพฎๅš) โ€” search, browse hot topics, read timelines, and explore user profiles from the terminal ๐Ÿฆ

README

weibo-cli

A CLI for Weibo (ๅพฎๅš) โ€” search, browse hot topics, read timelines, and explore user profiles from the terminal ๐Ÿฆ

English | ไธญๆ–‡

More Tools

  • twitter-cli โ€” Twitter/X CLI for timelines, bookmarks, and posting
  • xiaohongshu-cli โ€” Xiaohongshu (ๅฐ็บขไนฆ) CLI for notes and account workflows
  • bilibili-cli โ€” Bilibili CLI for videos, users, search, and feeds
  • discord-cli โ€” Discord CLI for local-first sync, search, and export
  • tg-cli โ€” Telegram CLI for local-first sync, search, and export

English

Features

Read:

  • Hot search: browse real-time trending topics and hashtags
  • Hot timeline: browse the trending feed
  • Home feed: browse your following timeline
  • Search: find weibos by keyword
  • Search trends: real-time trending sidebar data
  • Weibo detail: view a weibo with full text, media, and stats
  • Comments: read comments on any weibo
  • Reposts: view forwards/reposts of any weibo
  • User profiles: view user info, stats, and bio
  • User weibos: browse a userโ€™s published weibos
  • Following: view a userโ€™s following list
  • Followers: view a userโ€™s follower list
  • Structured output: export any data as JSON or YAML for scripting and AI agent integration

AI Agent Tip: Prefer --yaml for structured output unless strict JSON is required. Non-TTY stdout defaults to YAML automatically. Use --count to limit results.

Auth & Anti-Detection:

  • Cookie auth: auto-extract from Arc/Chrome/Edge/Firefox/Brave/Chromium/Opera/Vivaldi
  • QR code login: terminal-rendered QR code for Weibo App scan
  • Credential persistence: auto-save to ~/.config/weibo-cli/credential.json with 7-day TTL
  • Anti-detection: Chrome 145 User-Agent, Gaussian jitter, exponential backoff
  • Session auto-refresh: stale credentials trigger browser cookie re-extraction

Installation

# Recommended: uv tool (fast, isolated)
uv tool install kabi-weibo-cli

# Alternative: pipx
pipx install kabi-weibo-cli

Upgrade to the latest version:

uv tool upgrade kabi-weibo-cli

Install from source:

git clone [email protected]:jackwener/weibo-cli.git
cd weibo-cli
uv sync

Quick Start

# Login (auto-extract browser cookies or QR scan)
weibo login

# Browse hot search
weibo hot

# Search weibos by keyword
weibo search "็ง‘ๆŠ€"

# View hot timeline
weibo feed

# Check a weibo
weibo detail Qw06Kd98p

Usage

# โ”€โ”€โ”€ Auth โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
weibo login                            # Extract cookies from browser / QR login
weibo login --qrcode                   # QR code login directly (skip browser)
weibo login --cookie-source chrome     # Extract from specific browser
weibo logout                           # Clear saved credentials
weibo status                           # Check login status
weibo me                               # Show current user profile

# โ”€โ”€โ”€ Hot & Trending โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
weibo hot                              # Hot search list (50+ topics)
weibo hot --count 10                   # Limit results
weibo hot --json                       # JSON output
weibo trending                         # Real-time search trends
weibo trending --count 10              # Limit results
weibo trending --yaml                  # YAML output

# โ”€โ”€โ”€ Search โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
weibo search                  # Search weibos by keyword
weibo search "็ง‘ๆŠ€" --count 5            # Limit results
weibo search "็ง‘ๆŠ€" --page 2 --json     # Paginate + JSON output

# โ”€โ”€โ”€ Feed โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
weibo feed                             # Hot timeline
weibo feed --count 5                   # Limit results
weibo feed --json                      # JSON output
weibo home                             # Following timeline
weibo home --count 10                  # Limit count

# โ”€โ”€โ”€ Weibo Detail โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
weibo detail                  # View weibo with full stats
weibo detail Qw06Kd98p --json          # JSON output

# โ”€โ”€โ”€ Comments & Reposts โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
weibo comments                # View comments
weibo comments Qw06Kd98p --count 10    # Limit count
weibo comments Qw06Kd98p --json        # JSON output
weibo reposts                 # View reposts/forwards
weibo reposts Qw06Kd98p --count 5      # Limit count

# โ”€โ”€โ”€ User โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
weibo profile                     # User profile
weibo profile 1699432410 --json        # JSON output
weibo weibos                      # User's weibos
weibo weibos 1699432410 --count 5      # Limit count
weibo following                   # User's following list
weibo followers                   # User's follower list

Authentication

weibo-cli uses this auth priority:

  1. Saved credentials โ€” loads from ~/.config/weibo-cli/credential.json
  2. Browser cookies (recommended) โ€” auto-extract from Arc/Chrome/Edge/Firefox/Brave/Chromium/Opera/Vivaldi/Safari/LibreWolf
  3. QR code login โ€” terminal QR code, scan with Weibo App

Browser extraction is recommended โ€” it forwards ALL Weibo cookies and is closest to normal browser traffic.

Cookie TTL is 7 days by default. After expiry, the client automatically attempts browser re-extraction.

Troubleshooting

  • โš ๏ธ ๆœช็™ปๅฝ• โ€” Run weibo login to authenticate
  • ไผš่ฏๅทฒ่ฟ‡ๆœŸ โ€” Cookie expired, run weibo logout && weibo login
  • Unable to get key for cookie decryption (macOS Keychain):
    • SSH sessions: security unlock-keychain ~/Library/Keychains/login.keychain-db
    • Local terminal: Open Keychain Access โ†’ search โ€œChrome Safe Storageโ€ โ†’ Access Control โ†’ add Terminal โ†’ Save
  • Requests are slow โ€” intentional Gaussian jitter delay (~1s) to avoid triggering Weiboโ€™s risk control

Best Practices (Avoiding Bans)

  • Keep request volumes low โ€” use --count 10 instead of --count 100
  • Donโ€™t run too frequently โ€” the built-in rate limiter adds randomized delays
  • Use browser cookie extraction โ€” provides full cookie fingerprint
  • Cookie values are stored locally and never uploaded

Output Modes

  • Default Rich table for interactive terminal reading
  • --json for scripts and agent pipelines
  • --yaml for structured output (auto-detected when stdout is not a TTY)

Development

# Install dev dependencies
uv sync --extra dev --extra yaml

# Lint + tests
uv run ruff check .
uv run pytest tests/ -v

# Smoke tests (require browser cookies)
uv run pytest tests/ -v -m smoke

Project Structure

weibo_cli/
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ cli.py             # Click entry point (16 commands)
โ”œโ”€โ”€ client.py          # WeiboClient (17 API methods, rate-limit, retry)
โ”œโ”€โ”€ auth.py            # QR login + browser-cookie3 + credential persistence
โ”œโ”€โ”€ constants.py       # API endpoints, headers, Chrome 145 UA
โ”œโ”€โ”€ exceptions.py      # WeiboApiError hierarchy (6 error types)
โ””โ”€โ”€ commands/
    โ”œโ”€โ”€ _common.py     # structured_output_options, handle_command, strip_html, format_count
    โ”œโ”€โ”€ auth.py        # login/logout/status/me
    โ”œโ”€โ”€ search.py      # hot/feed/detail/comments/trending/search
    โ””โ”€โ”€ personal.py    # profile/weibos/following/followers/reposts/home

Use as AI Agent Skill

weibo-cli ships with a SKILL.md so AI agents can execute common Weibo workflows.

Skills CLI (Recommended)

npx skills add jackwener/weibo-cli
Flag Description
-g Install globally (user-level, shared across projects)
-a claude-code Target a specific agent
-y Non-interactive mode

Manual Install

mkdir -p .agents/skills
git clone [email protected]:jackwener/weibo-cli.git .agents/skills/weibo-cli

OpenClaw / ClawHub (Deprecated)

โš ๏ธ ClawHub install method is deprecated and no longer supported. Use Skills CLI or Manual Install above.


ไธญๆ–‡

ๅŠŸ่ƒฝ็‰นๆ€ง

้˜…่ฏป:

  • ๐Ÿ”ฅ ็ƒญๆœ๏ผšๅฎžๆ—ถ็ƒญ้—จ่ฏ้ข˜ๅ’Œๆ ‡็ญพ
  • ๐Ÿ“ฐ ็ƒญ้—จ Feed๏ผš็ƒญ้—จๆ—ถ้—ด็บฟ
  • ๐Ÿ  ๅ…ณๆณจ่€… Feed๏ผšๅ…ณๆณจ็”จๆˆท็š„ๆ—ถ้—ด็บฟ
  • ๐Ÿ” ๆœ็ดข๏ผšๆŒ‰ๅ…ณ้”ฎ่ฏๆœ็ดขๅพฎๅš
  • ๐Ÿ“ˆ ๆœ็ดข่ถ‹ๅŠฟ๏ผšๅฎžๆ—ถๆœ็ดข่ถ‹ๅŠฟไพง่พนๆ 
  • ๐Ÿ“ ๅพฎๅš่ฏฆๆƒ…๏ผšๆŸฅ็œ‹ๅฎŒๆ•ดๆญฃๆ–‡ใ€ๅช’ไฝ“ๅ’Œ็ปŸ่ฎกๆ•ฐๆฎ
  • ๐Ÿ’ฌ ่ฏ„่ฎบ๏ผšๆŸฅ็œ‹ๅพฎๅš่ฏ„่ฎบ
  • ๐Ÿ” ่ฝฌๅ‘๏ผšๆŸฅ็œ‹ๅพฎๅš่ฝฌๅ‘
  • ๐Ÿ‘ค ็”จๆˆท่ต„ๆ–™๏ผš็”จๆˆทไฟกๆฏๅ’Œ็ปŸ่ฎก
  • ๐Ÿ“‹ ็”จๆˆทๅพฎๅš๏ผšๆต่งˆ็”จๆˆทๅทฒๅ‘ๅธƒ็š„ๅพฎๅšๅˆ—่กจ
  • ๐Ÿ‘ฅ ๅ…ณๆณจๅˆ—่กจ๏ผšๆŸฅ็œ‹็”จๆˆท็š„ๅ…ณๆณจๅˆ—่กจ
  • ๐Ÿ‘ฅ ็ฒ‰ไธๅˆ—่กจ๏ผšๆŸฅ็œ‹็”จๆˆท็š„็ฒ‰ไธๅˆ—่กจ
  • ๐Ÿ“Š ็ป“ๆž„ๅŒ–่พ“ๅ‡บ๏ผšๆ”ฏๆŒ JSON ๅ’Œ YAML๏ผŒไพฟไบŽ่„šๆœฌๅ’Œ AI Agent ้›†ๆˆ

AI Agent ๆ็คบ๏ผš ้œ€่ฆ็ป“ๆž„ๅŒ–่พ“ๅ‡บๆ—ถไผ˜ๅ…ˆไฝฟ็”จ --yaml๏ผŒ้™ค้žไธ‹ๆธธๅฟ…้กปๆ˜ฏ JSONใ€‚stdout ไธๆ˜ฏ TTY ๆ—ถ้ป˜่ฎค่พ“ๅ‡บ YAMLใ€‚

่ฎค่ฏไธŽๅ้ฃŽๆŽง:

  • Cookie ่ฎค่ฏ๏ผšๆ”ฏๆŒ Arc/Chrome/Edge/Firefox/Brave ็ญ‰ 10+ ๆต่งˆๅ™จ่‡ชๅŠจๆๅ–
  • ไบŒ็ปด็ ็™ปๅฝ•๏ผš็ปˆ็ซฏๆธฒๆŸ“ไบŒ็ปด็ ๏ผŒ็”จๅพฎๅš APP ๆ‰ซ็ 
  • ๅ‡ญ่ฏๆŒไน…ๅŒ–๏ผš่‡ชๅŠจไฟๅญ˜ๅˆฐ ~/.config/weibo-cli/credential.json๏ผŒ7 ๅคฉ TTL
  • ๅๆฃ€ๆต‹๏ผšChrome 145 User-Agentใ€้ซ˜ๆ–ฏๆŠ–ๅŠจๅปถ่ฟŸใ€ๆŒ‡ๆ•ฐ้€€้ฟ้‡่ฏ•
  • ไผš่ฏ่‡ชๅŠจๅˆทๆ–ฐ๏ผš่ฟ‡ๆœŸๅ‡ญ่ฏ่‡ชๅŠจ่งฆๅ‘ๆต่งˆๅ™จ Cookie ้‡ๆๅ–

ๅฎ‰่ฃ…

# ๆŽจ่๏ผšuv tool๏ผˆๅฟซ้€Ÿใ€้š”็ฆป็Žฏๅขƒ๏ผ‰
uv tool install kabi-weibo-cli

# ๆˆ–่€…๏ผšpipx
pipx install kabi-weibo-cli

ๅ‡็บงๅˆฐๆœ€ๆ–ฐ็‰ˆๆœฌ๏ผš

uv tool upgrade kabi-weibo-cli

ไปŽๆบ็ ๅฎ‰่ฃ…๏ผš

git clone [email protected]:jackwener/weibo-cli.git
cd weibo-cli
uv sync

ไฝฟ็”จ็คบไพ‹

# ่ฎค่ฏ
weibo login                            # ไปŽๆต่งˆๅ™จๆๅ– Cookie / ไบŒ็ปด็ ๆ‰ซ็ 
weibo login --qrcode                   # ็›ดๆŽฅไบŒ็ปด็ ๆ‰ซ็ ็™ปๅฝ•
weibo login --cookie-source chrome     # ๆŒ‡ๅฎšๆต่งˆๅ™จๆๅ–
weibo logout                           # ๆธ…้™คๅทฒไฟๅญ˜ๅ‡ญ่ฏ
weibo status                           # ๆฃ€ๆŸฅ็™ปๅฝ•็Šถๆ€
weibo me                               # ๆŸฅ็œ‹ๅฝ“ๅ‰็”จๆˆทไฟกๆฏ

# ็ƒญๆœ
weibo hot                              # ็ƒญๆœๅˆ—่กจ๏ผˆ50+ ๆก๏ผ‰
weibo hot --count 10                   # ้™ๅˆถๆ•ฐ้‡
weibo hot --json                       # JSON ่พ“ๅ‡บ
weibo trending                         # ๆœ็ดข่ถ‹ๅŠฟ

# ๆœ็ดข
weibo search "็ง‘ๆŠ€"                     # ๆŒ‰ๅ…ณ้”ฎ่ฏๆœ็ดขๅพฎๅš
weibo search "็ง‘ๆŠ€" --count 5           # ้™ๅˆถๆ•ฐ้‡
weibo search "็ง‘ๆŠ€" --page 2            # ็ฟป้กต

# Feed
weibo feed                             # ็ƒญ้—จๆ—ถ้—ด็บฟ
weibo feed --count 5                   # ้™ๅˆถๆ•ฐ้‡
weibo home                             # ๅ…ณๆณจ่€…ๆ—ถ้—ด็บฟ

# ๅพฎๅš่ฏฆๆƒ…ไธŽ่ฏ„่ฎบ
weibo detail Qw06Kd98p                 # ๆŸฅ็œ‹ๅพฎๅš
weibo comments Qw06Kd98p               # ๆŸฅ็œ‹่ฏ„่ฎบ
weibo reposts Qw06Kd98p                # ๆŸฅ็œ‹่ฝฌๅ‘

# ็”จๆˆท
weibo profile 1699432410               # ็”จๆˆท่ต„ๆ–™
weibo weibos 1699432410                # ็”จๆˆทๅพฎๅšๅˆ—่กจ
weibo following 1699432410             # ็”จๆˆทๅ…ณๆณจๅˆ—่กจ
weibo followers 1699432410             # ็”จๆˆท็ฒ‰ไธๅˆ—่กจ

ๅธธ่ง้—ฎ้ข˜

  • โš ๏ธ ๆœช็™ปๅฝ• โ€” ๆ‰ง่กŒ weibo login ่ฎค่ฏ
  • ไผš่ฏๅทฒ่ฟ‡ๆœŸ โ€” Cookie ่ฟ‡ๆœŸ๏ผŒๆ‰ง่กŒ weibo logout && weibo login
  • ่ฏทๆฑ‚่พƒๆ…ขๆ˜ฏๆญฃๅธธ็š„ โ€” ๅ†…็ฝฎ้ซ˜ๆ–ฏ้šๆœบๅปถ่ฟŸ๏ผˆ~1s๏ผ‰ๆ˜ฏไธบไบ†ๆจกๆ‹Ÿไบบ็ฑปๆต่งˆ่กŒไธบ๏ผŒ้ฟๅ…่งฆๅ‘้ฃŽๆŽง

ไฝœไธบ AI Agent Skill ไฝฟ็”จ

Skills CLI๏ผˆๆŽจ่๏ผ‰

npx skills add jackwener/weibo-cli
ๅ‚ๆ•ฐ ่ฏดๆ˜Ž
-g ๅ…จๅฑ€ๅฎ‰่ฃ…๏ผˆ็”จๆˆท็บงๅˆซ๏ผŒ่ทจ้กน็›ฎๅ…ฑไบซ๏ผ‰
-a claude-code ๆŒ‡ๅฎš็›ฎๆ ‡ Agent
-y ้žไบคไบ’ๆจกๅผ

ๆ‰‹ๅŠจๅฎ‰่ฃ…

mkdir -p .agents/skills
git clone [email protected]:jackwener/weibo-cli.git .agents/skills/weibo-cli

License

Apache-2.0

View this README on GitHub

์ถ”์ฒœ ๋„๊ตฌ

๋‹ค๋ฅธ ํ‚ค์›Œ๋“œ๋ฅผ ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜ ํ•„ํ„ฐ๋ฅผ ์ œ๊ฑฐํ•ด ๋ณด์„ธ์š”.

์„ค์น˜

npx skillfish add jackwener/weibo-cli