Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Export Hacker News stories to CSV with the official API

Описание и применение

Автоматический скрипт на Python, использующий официальный API Hacker News, экспортирует топ‑сторис в CSV, поддерживает фильтрацию по ключевому слову и рейтингу, а также обновление списка через cron.

Задача

Need to pull top Hacker News stories into a CSV, filter by keyword or score, and keep a feed running without scraping.

Результат

Script outputs hn_top.csv with top 50 stories, supports keyword/score filtering, and can run hourly to maintain a feed.

Рабочий процесс

  • 1. Set BASE URL to https://hacker-news.firebaseio.com/v0
  • 2. GET /topstories.json and take first 50 ids
  • 3. For each id, GET /item/<id>.json
  • 4. Skip items that are null, dead, or deleted
  • 5. Append id, title, url (fallback to discussion link), author, score, comments to rows
  • 6. Write rows to hn_top.csv using csv.DictWriter
  • 7. Print number of saved stories
  • 8. (Optional) Add filter: if keyword not in title.lower() or score < threshold, continue
  • 9. Store seen ids in a JSON file to avoid duplicates
  • 10. Schedule script via cron or Task Scheduler hourly

Доказательства

Hacker News has a free, official API. You don't need to scrape the website.

Источник

The script above does the same job for free if you are happy to run it yourself.

Источник

  • Дата записи: 2026-11-02T21:14:10.098Z