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
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 mode
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 const { items } = await client.dataset(run.defaultDatasetId).listItems();
42 items.forEach((item) => {
43 console.dir(item);
44 });
45})();