Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Reddit Scraper Project

A comprehensive Reddit data collection toolkit with both Python PRAW and Node.js implementations for large-scale data analysis.

๐Ÿš€ Features

  • Official Reddit API - Safe, reliable, no rate limiting issues
  • Multiple scrapers - Python PRAW (advanced) and Node.js (simple)
  • High volume - 1000+ posts per request vs 50 with web scraping
  • Rich data - Comments, metadata, engagement metrics
  • Multiple formats - JSON, CSV, TXT outputs
  • Batch processing - Scrape multiple subreddits automatically
  • Data analysis - Built-in analysis and visualization tools

๐Ÿ“ Project Structure

reddit-scraper/
โ”œโ”€โ”€ config/
โ”‚   โ””โ”€โ”€ praw.ini                    # Reddit API credentials
โ”œโ”€โ”€ reddit-scrapers/
โ”‚   โ”œโ”€โ”€ reddit_scraper.py           # Main Python scraper (RECOMMENDED)
โ”‚   โ””โ”€โ”€ praw.ini                    # Config backup
โ”œโ”€โ”€ reddit-data/                    # Output files
โ”‚   โ”œโ”€โ”€ *.json                      # Structured data
โ”‚   โ”œโ”€โ”€ *.csv                       # Spreadsheet format
โ”‚   โ””โ”€โ”€ *.txt                       # Human readable
โ”œโ”€โ”€ scripts/
โ”‚   โ”œโ”€โ”€ setup.py                    # Setup verification
โ”‚   โ”œโ”€โ”€ bulk_scraper.py             # Multi-subreddit scraping
โ”‚   โ””โ”€โ”€ data_analyzer.py            # Data analysis tools
โ”œโ”€โ”€ examples/
โ”‚   โ”œโ”€โ”€ basic_usage.py              # Simple examples
โ”‚   โ””โ”€โ”€ advanced_usage.py           # Complex patterns
โ”œโ”€โ”€ quick_scraper.py                # Working simplified scraper
โ”œโ”€โ”€ test_reddit.py                  # Connection test
โ””โ”€โ”€ requirements.txt                # Python dependencies

โšก Quick Start

Method 1: Simple Scraper (Ready to Use)

# Basic scraping (works immediately)
python quick_scraper.py ceo --limit 100
python quick_scraper.py entrepreneur --limit 200
python quick_scraper.py startups --limit 150

# Different sorting methods
python quick_scraper.py investing --limit 100 --sort top
python quick_scraper.py business --limit 100 --sort new

Method 2: Advanced Python Scraper

# Setup (first time only)
python scripts/setup.py

# Basic usage
python reddit-scrapers/reddit_scraper.py ceo --limit 1000

# Advanced options
python reddit-scrapers/reddit_scraper.py entrepreneur --comprehensive
python reddit-scrapers/reddit_scraper.py startups --comments --limit 100

๐Ÿ›  Installation & Setup

Prerequisites

  • Python 3.11+ installed
  • Reddit account

1. Install Dependencies

pip install -r requirements.txt

2. Reddit API Setup

Your credentials are already configured in the working scraper. For advanced features:

  1. Go to https://www.reddit.com/prefs/apps
  2. Create new app (type: "script")
  3. Update config/praw.ini with your credentials

3. Verify Setup

python scripts/setup.py
python test_reddit.py

๐Ÿ“Š Scraping Commands

Basic Scraping

# Quick scraper (works out of the box)
python quick_scraper.py <subreddit> --limit <number>
python quick_scraper.py ceo --limit 500

# Advanced scraper (after setup)
python reddit-scrapers/reddit_scraper.py <subreddit> [options]

Advanced Options

# Different sorting methods
python reddit-scrapers/reddit_scraper.py ceo --sort hot --limit 1000
python reddit-scrapers/reddit_scraper.py ceo --sort new --limit 500
python reddit-scrapers/reddit_scraper.py ceo --sort top --time month --limit 1000

# Comprehensive scraping (multiple sorts)
python reddit-scrapers/reddit_scraper.py entrepreneur --comprehensive

# Include comments
python reddit-scrapers/reddit_scraper.py startups --comments --limit 100 --max-comments 20

# Bulk scraping multiple subreddits
python scripts/bulk_scraper.py

Batch Processing

# Interactive bulk scraper
python scripts/bulk_scraper.py

# Choose from predefined collections:
# 1. Business & Finance (ceo, entrepreneur, startups, business, investing)
# 2. Technology (programming, MachineLearning, webdev, python)
# 3. Popular (AskReddit, todayilearned, worldnews, science)
# 4. Custom (enter your own subreddits)

๐Ÿ“ˆ Data Analysis

Built-in Analysis

# Analyze all scraped data
python scripts/data_analyzer.py

# Run usage examples
python examples/basic_usage.py
python examples/advanced_usage.py

Output Analysis

Each scrape generates:

  • JSON: reddit_<subreddit>_<type>_<count>posts_<timestamp>.json
  • CSV: reddit_<subreddit>_<type>_<count>posts_<timestamp>.csv
  • TXT: reddit_<subreddit>_<type>_<count>posts_<timestamp>.txt

๐ŸŽฏ Use Cases & Examples

Content Research

# Market research
python quick_scraper.py entrepreneur --limit 1000
python quick_scraper.py startups --limit 1000

# Trend analysis
python reddit-scrapers/reddit_scraper.py technology --sort rising --limit 500

Academic Research

# Large dataset collection
python reddit-scrapers/reddit_scraper.py science --comprehensive
python reddit-scrapers/reddit_scraper.py AskReddit --comments --limit 500

Business Intelligence

# Industry monitoring
python scripts/bulk_scraper.py
# Select business collection for comprehensive industry analysis

๐Ÿ”ง Configuration

Quick Scraper

Edit variables in quick_scraper.py:

# Default settings - modify as needed
subreddit = 'ceo'
limit = 100
sort_method = 'hot'

Advanced Scraper

All options via command line:

python reddit-scrapers/reddit_scraper.py [subreddit] \
  --limit 1000 \
  --sort hot|new|top|rising|controversial \
  --time all|year|month|week|day \
  --comprehensive \
  --comments \
  --max-comments 50

๐Ÿ“Š Data Structure

Post Data

{
  "post_number": 1,
  "id": "unique_id",
  "title": "Post title",
  "author": "username",
  "score": 150,
  "num_comments": 45,
  "created_date": "2025-09-11 21:02:43",
  "url": "https://reddit.com/...",
  "subreddit": "ceo",
  "is_self": true,
  "selftext": "Post content...",
  "word_count": 245,
  "scraped_at": "2025-09-11T21:02:43"
}

Comment Data (when enabled)

{
  "comment_id": "unique_id",
  "author": "username",
  "body": "Comment text...",
  "score": 25,
  "created_date": "2025-09-11 21:05:12"
}

๐Ÿšฆ Rate Limits & Performance

Reddit API Limits

  • 600 requests per 10 minutes (authenticated)
  • 1000 posts maximum per single request
  • Built-in rate limiting in all scrapers

Performance Comparison

Method Posts/Request Reliability Speed Comments
PRAW API 1000+ Very High Fast Full Access
Web Scraping 50-100 Medium Slow Limited

Scaling Guidelines

# Small datasets (< 500 posts)
python quick_scraper.py subreddit --limit 500

# Medium datasets (500-2000 posts)
python reddit-scrapers/reddit_scraper.py subreddit --comprehensive

# Large datasets (2000+ posts)
python scripts/bulk_scraper.py

๐Ÿงน Cleanup & Maintenance

Data Management

# View scraped data
dir reddit-data

# Clean old files (keep recent only)
# Windows:
forfiles /p reddit-data /s /m *.* /d -30 /c "cmd /c del @path"

# Archive large datasets
mkdir archived-data
move reddit-data\*.json archived-data\

File Organization

# Organize by subreddit
mkdir reddit-data\ceo reddit-data\entrepreneur reddit-data\startups
# Move files manually or use script

System Maintenance

# Update dependencies
pip install --upgrade -r requirements.txt

# Clean Python cache
python -c "import shutil; shutil.rmtree('__pycache__', ignore_errors=True)"

# Test connection periodically
python test_reddit.py

๐Ÿ”ฎ Future Scope & Enhancements

Immediate Improvements

  • Real-time monitoring - Continuous scraping with webhooks
  • Database integration - PostgreSQL/MongoDB storage
  • API rate optimization - Smarter request batching
  • Duplicate detection - Cross-scrape deduplication
  • Error recovery - Resume interrupted scrapes

Data Analysis Features

  • Sentiment analysis - Automated mood detection
  • Topic modeling - LDA/NMF clustering
  • Network analysis - User interaction graphs
  • Trend detection - Time series analysis
  • Visualization dashboard - Web-based analytics

Advanced Functionality

# Planned features
# Real-time streaming
python reddit-scrapers/stream_scraper.py --live --subreddit all

# Database storage
python reddit-scrapers/reddit_scraper.py ceo --database postgres://...

# ML preprocessing
python scripts/ml_preprocessor.py --input reddit-data/ --output features/

Integration Opportunities

  • Elasticsearch - Full-text search and analytics
  • Apache Kafka - Stream processing
  • Docker - Containerized deployment
  • AWS/GCP - Cloud-native scaling
  • Airflow - Workflow orchestration

Research Applications

  • Academic studies - Large-scale social media research
  • Market research - Consumer sentiment analysis
  • Content strategy - Viral content pattern analysis
  • Crisis monitoring - Brand reputation tracking
  • Competitive intelligence - Industry trend analysis

๐Ÿ” Troubleshooting

Common Issues

# Connection errors
python test_reddit.py  # Verify credentials

# No data returned
# Check subreddit exists and is public

# Rate limiting
# Built-in delays handle this automatically

# Memory issues with large datasets
# Use --limit to control batch sizes

Performance Optimization

# For large scrapes, use smaller batches
python reddit-scrapers/reddit_scraper.py ceo --limit 500
# Then combine datasets manually

# Monitor memory usage
python -c "import psutil; print(f'Memory: {psutil.virtual_memory().percent}%')"

๐Ÿ“ž Support & Contributing

Getting Help

  1. Check existing scraped data in reddit-data/
  2. Run python test_reddit.py to verify connection
  3. Review error messages in console output
  4. Ensure Reddit API credentials are valid

Data Analysis Resources

  • Use CSV files with Excel/Google Sheets for quick analysis
  • Import JSON files into Python/R for advanced analysis
  • TXT files for human review and pattern identification

This toolkit provides a foundation for large-scale Reddit data collection and analysis, with room for significant expansion based on your specific research needs.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors