Hacker News Data Scraper avatar
Hacker News Data Scraper
Try for free

3 days trial then $10.00/month - No credit card required now

View all Actors
Hacker News Data Scraper

Hacker News Data Scraper

epctex/hackernews-scraper
Try for free

3 days trial then $10.00/month - No credit card required now

Extract Y Combinator's Hacker News based on any search criteria. Crawl the front page, Show HN, Ask HN, news, job listings, and historical data. Get links, titles, comments, ratings, and more!

The code examples below show how to run the Actor and get its results. To run the code, you need to have an Apify account. Replace <YOUR_API_TOKEN> in the code with your API token, which you can find under Settings > Integrations in Apify Console. Learn more

Node.js

Python

curl

1import { ApifyClient } from 'apify-client';
2
3// Initialize the ApifyClient with your Apify API token
4const client = new ApifyClient({
5    token: '<YOUR_API_TOKEN>',
6});
7
8// Prepare Actor input
9const input = {
10    "startUrls": [
11        {
12            "url": "https://news.ycombinator.com/front"
13        },
14        {
15            "url": "https://news.ycombinator.com/show"
16        },
17        {
18            "url": "https://news.ycombinator.com/jobs"
19        },
20        {
21            "url": "https://news.ycombinator.com"
22        },
23        {
24            "url": "https://news.ycombinator.com/item?id=26566373"
25        }
26    ],
27    "maxItems": 50,
28    "endPage": 1,
29    "extendOutputFunction": ($) => { return {} },
30    "proxy": {
31        "useApifyProxy": true
32    }
33};
34
35(async () => {
36    // Run the Actor and wait for it to finish
37    const run = await client.actor("epctex/hackernews-scraper").call(input);
38
39    // Fetch and print Actor results from the run's dataset (if any)
40    console.log('Results from dataset');
41    console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
42    const { items } = await client.dataset(run.defaultDatasetId).listItems();
43    items.forEach((item) => {
44        console.dir(item);
45    });
46})();
47
48// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs
Developer
Maintained by Community
Actor metrics
  • 3 monthly users
  • 100.0% runs succeeded
  • Created in Mar 2021
  • Modified about 19 hours ago