1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "scrapingMode": "json_api",
12 "redditCredentials": [],
13 "startUrls": [],
14 "subreddits": [
15 "webdev"
16 ],
17 "scrapeOptions": {
18 "posts": true,
19 "comments": false,
20 "users": false,
21 "subredditInfo": false
22 },
23 "filters": {
24 "sortBy": "hot",
25 "timeRange": "all",
26 "minUpvotes": 0
27 },
28 "limits": {
29 "maxPosts": 5,
30 "maxCommentsPerPost": 5,
31 "maxCommentDepth": 2
32 }
33};
34
35
36const run = await client.actor("kalirobot/reddit-scraper-pro").call(input);
37
38
39console.log('Results from dataset');
40console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
41const { items } = await client.dataset(run.defaultDatasetId).listItems();
42items.forEach((item) => {
43 console.dir(item);
44});
45
46