Hacker News Top Stories avatar

Hacker News Top Stories

Pricing

Pay per usage

Go to Apify Store
Hacker News Top Stories

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.

Pricing

Pay per usage

Rating

0.0

(0)

Developer

Jordan C

Jordan C

Maintained by Community

Actor stats

0

Bookmarked

1

Total users

0

Monthly active users

2 days ago

Last modified

Categories

Share

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

FieldTypeDefaultDescription
sectionenumtopHN section: top, new, ask, show, jobs
maxResultsinteger30Maximum number of stories to collect (1–500)

Output Fields

FieldTypeDescription
rankintegerPosition on the page (1-indexed)
titlestringStory title
urlstringLink to the story
domainstringDomain extracted from the URL
pointsintegerUpvote score
authorstringSubmission author username
commentsintegerNumber of comments (0 if none)
commentUrlstringLink to the HN discussion page
postedAgestringRelative time string (e.g., "2 hours ago")
scrapedAtstringISO 8601 timestamp when scraped

Usage

# Install dependencies
npm install
# Run locally (uses .actor/input_schema.json defaults or storage/key_value_stores/default/INPUT.json)
apify run
# Build for production
npm run build
# Validate input schema
apify validate-schema

Local Development

  1. Set input in storage/key_value_stores/default/INPUT.json or use apify run --input:
    { "section": "show", "maxResults": 10 }
  2. Run: npm run start:dev or apify run

Deployment

apify login
apify 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) and story-result ($0.002 per story)