Downloads images from one or multiple subreddits though Reddit's own API.
Setup:
pip install requests
Reddit heavily throttles anonymous requests, so set up free API credentials: Go to reddit.com/prefs/apps and create a “script” app. Then run:
export REDDIT_CLIENT_ID=your_id export REDDIT_CLIENT_SECRET=your_secret
Without these, the script still works, but it uses the public JSON endpoints at about one request every 6 seconds.
Usage: python reddit_image_dl.py SUBREDDIT_NAME --sort top --time all --limit 1000 Replace SUBREDDIT_NAME with the subreddit you want, for example:
bash python reddit_image_dl.py wallpapers --sort top --time all --limit 1000
Reddit only returns about the top 1,000 posts of all time, so --limit 1000 is roughly the most you’ll get from one run. To scrape several subreddits at once, list them with spaces: python reddit_image_dl.py wallpapers earthporn ....