Hacker News Top Stories
Pricing
Pay per usage
Go to Apify Store
Hacker News Top Stories
Scrape top stories from Hacker News by section. Extract story titles, URLs, points, authors, and comment counts from the front page, new, ask, show, or jobs sections.
Hacker News Top Stories Scraper
A Cheerio-based Apify Actor that scrapes top stories from Hacker News with pagination support.
Features
- Scrapes stories by section: Top, New, Ask HN, Show HN, Jobs
- Extracts: rank, title, URL, domain, points, author, comment count, comment URL, posted age, scraped timestamp
- Paginates through the "More" link to reach the requested number of results
- Configurable max results (1–500, default 30)
Input
| Field | Type | Default | Description |
|---|---|---|---|
section | enum | top | HN section: top, new, ask, show, jobs |
maxResults | integer | 30 | Maximum number of stories to collect (1–500) |
Output Fields
| Field | Type | Description |
|---|---|---|
rank | integer | Position on the page (1-indexed) |
title | string | Story title |
url | string | Link to the story |
domain | string | Domain extracted from the URL |
points | integer | Upvote score |
author | string | Submission author username |
comments | integer | Number of comments (0 if none) |
commentUrl | string | Link to the HN discussion page |
postedAge | string | Relative time string (e.g., "2 hours ago") |
scrapedAt | string | ISO 8601 timestamp when scraped |
Usage
# Install dependenciesnpm install# Run locally (uses .actor/input_schema.json defaults or storage/key_value_stores/default/INPUT.json)apify run# Build for productionnpm run build# Validate input schemaapify validate-schema
Local Development
- Set input in
storage/key_value_stores/default/INPUT.jsonor useapify run --input:{ "section": "show", "maxResults": 10 } - Run:
npm run start:devorapify run
Deployment
apify loginapify push
Technical Notes
- Built with Crawlee CheerioCrawler — no browser overhead, fast scraping
- Automatically paginates through HN's "More" links
- Handles Ask HN / Show HN relative URLs
- Uses Apify proxy configuration for reliable access
- PPE charge events:
search-start($0.005) andstory-result($0.002 per story)