介绍
# Hacker News
用于 Hacker News API 的 CLI 工具。无需身份验证。
## CLI 使用方法
运行 `scripts/hn.sh <command>`。所有命令都支持 `--json` 以输出原始 JSON。
### 浏览故事
```bash # Top/trending stories (default 10) scripts/hn.sh top scripts/hn.sh top --limit 20
# Other lists scripts/hn.sh new --limit 5 # newest scripts/hn.sh best --limit 10 # highest rated scripts/hn.sh ask # Ask HN scripts/hn.sh show # Show HN scripts/hn.sh jobs # job postings ```
### 查看项目详情与评论
```bash # Full item details (story, comment, job, poll) scripts/hn.sh item 12345678
# Top comments on a story scripts/hn.sh comments 12345678 scripts/hn.sh comments 12345678 --limit 10 --depth 2 ```
### 用户资料
```bash scripts/hn.sh user dang ```
### 搜索
```bash # Basic search scripts/hn.sh search "rust programming"
# With filters scripts/hn.sh search "LLM" --type story --sort date --period week --limit 5 scripts/hn.sh search "hiring remote" --type comment --period month ```
### 谁在招聘
```bash # Latest "Who is hiring?" job postings scripts/hn.sh whoishiring scripts/hn.sh whoishiring --limit 20 ```
## 常见工作流
| 用户询问 | 命令 | |---|---| | "HN 上什么在热门讨论?" | `scripts/hn.sh top` | | "最新的 Ask HN 帖子" | `scripts/hn.sh ask` | | "在 HN 上搜索 X" | `scripts/hn.sh search "X"` | | "给我看故事 Y 的评论" | `scripts/hn.sh comments Y` | | "谁在招聘?" | `scripts/hn.sh whoishiring` | | "告诉我关于 HN 用户 Z 的信息" | `scripts/hn.sh user Z` |
## 注意事项
- 故事列表使用并行获取以提高速度 - 评论/简介中的 HTML 会自动转换为纯文本 - 时间戳显示为相对时间("2h ago"、"3d ago") - 有关 API 的详细信息,请参阅 [references/api.md](references/api.md)