# Reddit Advanced Scraper (`crazee-media/reddit-advanced-scraper`) Actor

The Advanced Reddit Scraper is able to scrape reddit posts and comments and returns them in 1 output item per post.

- **URL**: https://apify.com/crazee-media/reddit-advanced-scraper.md
- **Developed by:** [Crazee Media](https://apify.com/crazee-media) (community)
- **Categories:** Automation, Social media, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Reddit Advanced Scraper - Any Subreddit (Anti-Rate-Limit)

Powerful Reddit scraper for **any subreddit** with advanced anti-rate-limit protection. Scrape posts and comments with full configurability.

### ✨ Features

- **📊 Scrape Any Subreddit** - Choose any subreddit (AskReddit, technology, gaming, science, etc.)
- **💬 Full Comment Threads** - Scrape nested comments with configurable depth
- **🛡️ Anti-Rate-Limit Protection** - Automatic session rotation, adaptive delays, user agent switching
- **🎯 Fully Configurable** - Control post count, comment depth, delays, and more
- **📤 Webhook Support** - Send results to your webhook (n8n, Zapier, etc.)
- **📈 Real-Time Logging** - Track progress with detailed logs
- **🔄 Adaptive Intelligence** - Automatically adjusts delays based on rate limiting

### 🚀 Quick Start

#### Input Parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| **subreddit** | string | AskReddit | Name of subreddit (without r/) |
| **sort** | enum | hot | Sort posts by: hot, new, top, rising |
| **maxPosts** | integer | 1000 | Maximum posts to scrape (1-10000) |
| **maxComments** | integer | 50 | Max comments per post (0-500) |
| **maxDepth** | integer | 5 | Comment nesting depth (0-10) |
| **baseDelay** | integer | 6 | Base delay between requests in seconds |
| **sessionRotationRequests** | integer | 50 | Rotate session every N requests |
| **webhookUrl** | string | null | Optional webhook URL for results |
| **adaptiveDelays** | boolean | true | Auto-adjust delays based on rate limiting |

#### Example Configuration

```json
{
  "subreddit": "technology",
  "sort": "hot",
  "maxPosts": 500,
  "maxComments": 100,
  "maxDepth": 5,
  "baseDelay": 6,
  "adaptiveDelays": true
}
```

### 📦 Output Format

Each scraped post includes:

```json
{
  "title": "Post title",
  "author": "username",
  "subreddit": "technology",
  "score": 12345,
  "num_comments": 567,
  "created_utc": "2026-01-01T12:00:00Z",
  "url": "https://reddit.com/...",
  "permalink": "https://old.reddit.com/r/technology/...",
  "selftext": "Post body text",
  "is_self": true,
  "comments": [
    {
      "author": "commenter",
      "body": "Comment text",
      "score": 123,
      "depth": 0,
      "replies": [...]
    }
  ],
  "total_comments_scraped": 45
}
```

### 🛡️ Anti-Rate-Limit Features

#### 1. Session Rotation

Automatically creates fresh sessions every 50 requests (configurable) with new identities.

#### 2. Adaptive Delays

- Starts with base delay (default 6s)
- Increases exponentially when rate limited
- Gradually decreases with successful requests
- Adds random jitter to appear more human

#### 3. User Agent Rotation

Rotates through 10+ different user agents:

- Chrome (Windows, Mac, Linux)
- Firefox (Windows, Mac, Linux)
- Safari (Mac)

#### 4. Exponential Backoff

Automatically backs off with increasing delays on failures (2s, 4s, 8s, 16s, etc.)

#### 5. Smart Request Timing

- Random jitter on all delays (±20%)
- Configurable base delays
- Respects Reddit's Retry-After headers

### 🎯 Use Cases

- **Market Research** - Analyze sentiment and trends in specific communities
- **Academic Research** - Collect data for social media studies
- **Community Analysis** - Understand discussion patterns and popular topics
- **Content Discovery** - Find trending posts and discussions
- **Data Collection** - Build datasets for ML/AI training
- **Monitoring** - Track specific subreddits for mentions or topics

### 💡 Tips for Best Results

#### Avoid Rate Limits

- Use default delay of 6+ seconds
- Enable adaptive delays
- Keep session rotation at 50 requests
- Don't scrape too many posts at once (stay under 1000)

#### Get More Data

- Increase `maxComments` for deeper discussions
- Increase `maxDepth` for nested reply chains
- Use `sort: "new"` for latest content
- Use `sort: "top"` for highest quality

#### Performance

- Lower `maxComments` for faster scraping
- Reduce `maxDepth` if you don't need deep threads
- Increase `baseDelay` if you get rate limited

### 🔗 Webhook Integration

Send results to your webhook endpoint (n8n, Zapier, Make, etc.):

```json
{
  "webhookUrl": "https://your-webhook.com/endpoint"
}
```

Webhook payload format:

```json
{
  "timestamp": "2026-01-01T12:00:00Z",
  "scraper_type": "reddit",
  "action": "scrape_complete",
  "count": 500,
  "metadata": {
    "version": "2.0-apify",
    "source": "Apify Actor",
    "scraped_at": "2026-01-01T12:00:00Z",
    "count": 500
  },
  "data": [...]
}
```

### Deploy to Apify

1. Log in to Apify:
   ```bash
   apify login
   ```

2. Deploy your Actor:
   ```bash
   apify push
   ```

3. Find it under [Actors -> My Actors](https://console.apify.com/actors?tab=my)

### ⚠️ Important Notes

- Reddit's old.reddit.com interface is used (more scraping-friendly)
- No API authentication required (uses web scraping)
- Respects Reddit's rate limits automatically
- Data is saved to Apify dataset storage
- Always check Reddit's Terms of Service for your use case

### 📊 Popular Subreddits to Scrape

- r/AskReddit - Popular Q\&A discussions
- r/technology - Tech news and discussions
- r/science - Scientific articles and comments
- r/gaming - Gaming community discussions
- r/news - Breaking news and comments
- Any other public subreddit!

### 🔧 Technical Details

- **Built with**: Python, BeautifulSoup, Requests, Apify SDK
- **Parsing**: lxml parser for fast HTML processing
- **Session Management**: Connection pooling for efficiency
- **Error Handling**: Automatic retries with exponential backoff
- **Logging**: Detailed progress tracking via Apify SDK

***

**Version**: 2.0
**Built with advanced anti-rate-limit technology**

# Actor input Schema

## `subreddit` (type: `string`):

Name of ANY subreddit to scrape (without r/). Examples: AskReddit, technology, gaming, science, etc.

## `sort` (type: `string`):

How to sort posts

## `maxPosts` (type: `integer`):

Maximum number of posts to scrape

## `maxComments` (type: `integer`):

Maximum number of comments to scrape per post

## `maxDepth` (type: `integer`):

How deep to scrape nested comment replies

## `baseDelay` (type: `integer`):

Base delay between requests (adaptive delays will adjust this)

## `sessionRotationRequests` (type: `integer`):

Rotate session every N requests

## `webhookUrl` (type: `string`):

Send results to this webhook URL when complete

## `adaptiveDelays` (type: `boolean`):

Automatically adjust delays based on rate limiting

## `skipEmptyBody` (type: `boolean`):

Skip posts that have no body text (title-only posts). When enabled, the scraper will collect extra posts to ensure you get the requested number of posts with body content.

## `proxyConfiguration` (type: `object`):

Use Apify residential proxies to avoid IP blocks (REQUIRED to avoid 403 errors). Residential proxies use additional credits.

## Actor input object example

```json
{
  "subreddit": "AskReddit",
  "sort": "hot",
  "maxPosts": 1000,
  "maxComments": 50,
  "maxDepth": 5,
  "baseDelay": 6,
  "sessionRotationRequests": 50,
  "adaptiveDelays": true,
  "skipEmptyBody": true,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "subreddit": "AskReddit",
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("crazee-media/reddit-advanced-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "subreddit": "AskReddit",
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("crazee-media/reddit-advanced-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "subreddit": "AskReddit",
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call crazee-media/reddit-advanced-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=crazee-media/reddit-advanced-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/PjqfVf3eR1tWMcJVs/builds/ThYtsoHc15fFKZc5L/openapi.json
