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 ๐ฆ
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
--yamlfor structured output unless strict JSON is required. Non-TTY stdout defaults to YAML automatically. Use--countto 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.jsonwith 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:
- Saved credentials โ loads from
~/.config/weibo-cli/credential.json - Browser cookies (recommended) โ auto-extract from Arc/Chrome/Edge/Firefox/Brave/Chromium/Opera/Vivaldi/Safari/LibreWolf
- 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
โ ๏ธ ๆช็ปๅฝโ Runweibo loginto authenticateไผ่ฏๅทฒ่ฟๆโ Cookie expired, runweibo logout && weibo loginUnable 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
- SSH sessions:
- 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 10instead 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
--jsonfor scripts and agent pipelines--yamlfor 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
์ถ์ฒ ๋๊ตฌ
๋ค๋ฅธ ํค์๋๋ฅผ ์ ๋ ฅํ๊ฑฐ๋ ํํฐ๋ฅผ ์ ๊ฑฐํด ๋ณด์ธ์.
์ค์น
npx skillfish add jackwener/weibo-cli