Weibo CLI
Query Weibo public data via weibo command. No login or API key required.
Installation
CODEBLOCK0
Authentication
No authentication required. The CLI uses Weibo's public mobile web API with auto-generated visitor cookies. All data accessed is publicly available on weibo.com.
Optional: Set WEIBO_COOKIE environment variable for higher rate limits (your own login cookie).
Commands
Hot Searches
CODEBLOCK1
Search
CODEBLOCK2
User
CODEBLOCK3
Post
CODEBLOCK4
Output
Always use --json for structured output. Parse with jq:
CODEBLOCK5
Rate Limiting
If you see rate limit errors, wait 1-2 minutes. The CLI auto-retries with exponential backoff.
技能名称: weibo-cli
详细描述:
Weibo CLI
通过 weibo 命令查询微博公开数据。无需登录或API密钥。
安装
bash
全局安装
npm install -g @marvae24/weibo-cli
或本地安装(更安全)
npm install @marvae24/weibo-cli
npx @marvae24/weibo-cli hot
身份验证
无需身份验证。 该CLI使用微博公开移动网页API,并自动生成访客Cookie。所有访问的数据均为weibo.com上的公开信息。
可选:设置 WEIBO_COOKIE 环境变量以获得更高频率限制(使用您自己的登录Cookie)。
命令
热搜
bash
热搜前50
weibo hot --json
限制结果数量
weibo hot --limit 10 --json
话题详情(阅读量、讨论量)
weibo hot AI --json
搜索
bash
搜索帖子(默认)
weibo search 咖啡 --json
搜索用户
weibo search 咖啡 --type user --json
搜索话题并附带统计信息
weibo search 旅行 --type topic --stats --json
类型:content, user, topic, realtime, hot, video, image, article
weibo search 猫 --type video --limit 5 --json
用户
bash
个人资料(需要UID)
weibo user 123456789 --json
用户动态
weibo user 123456789 --feeds --json
热门动态(按互动量排序)
weibo user 123456789 --feeds --hot --json
关注/粉丝列表
weibo user 123456789 --following --json
weibo user 123456789 --followers --json
分页
weibo user 123456789 --feeds --limit 20 --page 2 --json
帖子
bash
帖子详情
weibo post 5000000000000000 --json
评论
weibo post 5000000000000000 --comments --json
输出
始终使用 --json 获取结构化输出。配合 jq 解析:
bash
weibo hot --limit 10 --json | jq .[] | {keyword: .description, heat: .trending}
weibo user 123456789 --json | jq {name: .screenname, followers: .followerscount}
weibo search coffee --json | jq .[0] | {text: .text, reposts: .reposts_count}
频率限制
如果遇到频率限制错误,请等待1-2分钟。CLI会自动以指数退避策略重试。