This repository provides a light-weight Reddit scraper built on PRAW. It searches a fixed list of subreddits for domain keywords, summarizes post bodies and discussion threads, and streams the results to CSV.
- Fixed subreddit list under version control
- Naïve word-count summarization of posts and discussions
- CSV export with streaming writes
- Rate-limit friendly delays between queries
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtCreate a Reddit app at https://www.reddit.com/prefs/apps and set the following environment variables. Copy .env.example to .env and fill in your values.
cp .env.example .env
# edit .env with your credentials
# then load them for this shell
set -a; source .env; set +aRequired variables:
REDDIT_CLIENT_IDREDDIT_CLIENT_SECRETREDDIT_USER_AGENT(any descriptive string)
You can also put these variables directly in the python script.
python reddit-scraper.pyThe script writes reddit_scrapped.csv in the project root.
Edit the constants near the top of reddit-scraper.py to adjust:
SUBREDDITS: the subreddits to scanSEARCH_KEYWORDS: the domain keywords to query in each subredditSEARCH_LIMIT: number of posts per (subreddit, keyword) pairREQUEST_DELAY: seconds to sleep between keyword batchesCSV_FILE: output path
subredditsearch_querytitlepost_summarydiscussion_summaryscoreurlcreated_utc
- The script fetches and flattens all comments for each post in order to summarize discussion. This is network intensive for very popular threads.
- Respect Reddit's API terms and community rules. Add larger delays if you encounter rate-limit errors.
Author: Adeel Ahsan
Website: www.aeronautyy.com