介绍
# Reddit CLI
使用您的会话 Cookie 阅读 Reddit。无需 API 密钥。
## 快速开始
```bash reddit-cli posts programming 10 # Get 10 hot posts reddit-cli posts gaming 5 top # Get top 5 posts reddit-cli search "python tutorial" # Search all Reddit reddit-cli search "help" --sub linux # Search in subreddit reddit-cli info AskReddit # Subreddit info reddit-cli check # Test connection ```
## 命令
### 从 Subreddit 获取帖子 ```bash reddit-cli posts <subreddit> [limit] [sort] ``` - limit:帖子数量(默认:10) - sort:排序方式 hot, new, top, rising(默认:hot)
### 搜索 Reddit ```bash reddit-cli search <query> [--sub <subreddit>] [limit] ```
### 获取 Subreddit 信息 ```bash reddit-cli info <subreddit> ```
### 检查连接 ```bash reddit-cli check ```
## 环境变量
在 `~/.bashrc` 中设置: ```bash export REDDIT_SESSION="your_reddit_session_cookie" export TOKEN_V2="your_token_v2_cookie" # optional ```
## 获取 Cookie
1. 访问 reddit.com(已登录) 2. DevTools (F12) → Application → Cookies → reddit.com 3. 复制 `reddit_session` 值 4. 可选:复制 `token_v2` 值
## 注意事项
- Cookie 会过期,您可能需要定期刷新 - 遵守 Reddit 的速率限制 - 仅供个人使用