SuperAPI AI 工具集

hacker-news-scraper

写作与研究

查看项目

更新于 10-16 06:03

技能介绍

Hacker News Scraper 通过免费的 Algolia HN Search API 搜索 Hacker News,无需 Apify token 或 API key。

用途

该工具用于搜索 Hacker News 上的帖子(story)、评论(comment)、Ask HN 和 Show HN 内容,适合查找 HN 讨论、追踪提及以及发现相关内容。

主要能力

  • 使用 Algolia HN Search API 的 search_by_date 端点进行查询。
  • 通过 numericFilters=created_at_i>{unix_timestamp} 实现服务端日期过滤。
  • 自动分页直到达到 max-results 上限。
  • 将结果规范化为统一的数据结构。
  • 可选地在客户端进行额外关键词过滤。
  • 按 points 降序排序,并输出 JSON 或摘要。

使用方式

唯一依赖:安装 requests 库(pip install requests)。

示例命令:

Stories about AI content marketing in last week

python3 skills/hacker-news-scraper/scripts/search_hn.py
--query "AI content marketing" --days 7

Show HN posts in last month (summary view)

python3 skills/hacker-news-scraper/scripts/search_hn.py
--query "" --tags show_hn --days 30 --output summary

Comments mentioning a specific tool

python3 skills/hacker-news-scraper/scripts/search_hn.py --query "LangChain" --tags comment --days 14 --max-results 20

CLI 参数

参数 默认值 说明
--query 必填 搜索查询
--days 7 向前搜索的天数
--tags story 条目类型:story、comment、ask_hn、show_hn
--max-results 50 最大返回结果数
--keywords 无 额外的过滤关键词(逗号分隔,OR 逻辑)
--output json 输出格式:json 或 summary

输出格式

输出为结构化 JSON 记录,每条记录包含以下字段:id、title、url、author、points、num_comments、created_at、hn_url、text。

示例:

{
  "id": "12345678",
  "title": "Show HN: My new tool",
  "url": "https://example.com",
  "author": "username",
  "points": 42,
  "num_comments": 15,
  "created_at": "2026-02-18T12:00:00.000Z",
  "hn_url": "https://news.ycombinator.com/item?id=12345678",
  "text": ""
}

适用场景

  • 查找特定主题在 Hacker News 上的最新讨论。
  • 追踪品牌、产品或工具在 HN 上的提及。
  • 发现 Show HN 新项目。
  • 按时间窗口收集评论用于分析。

限制与成本

成本:免费。无需 API key、无需 Apify credits,在合理范围内无速率限制。工具的可用性和返回结果受 Algolia HN Search API 本身约束,具体使用限制资料中暂未提供更多细节。