Skip to content

Instantly share code, notes, and snippets.

@Xuij
Last active April 6, 2017 13:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xuij/d0f1f496af9aad907f5936639decd8c3 to your computer and use it in GitHub Desktop.
Save Xuij/d0f1f496af9aad907f5936639decd8c3 to your computer and use it in GitHub Desktop.
Python script to save your saved reddit threads, and then wget them all!
#pip install praw -- first install praw through pip
#the command looks like python prawScript1.py >redditSaved.txt
#to get praw to connect to the API you need to register (create another app, choose script) : https://www.reddit.com/prefs/apps/
#tutorial : https://praw.readthedocs.io/en/latest/getting_started/authentication.html
#replace secretGOESHERE, accountPassword and accountUsername(twice in this script)
import praw
import sys
reddit = praw.Reddit(client_id='clientID', client_secret='secretGOESHERE', password='accountPassword', user_agent='android:com.example.myredditapp:v1.2.3', username='accountUsername')
def get(n,i,z):
try:
n.url
except AttributeError:
try:
get(n.parent(),i,z+1)
except AttributeError:
print("attribute error")
else:
if z == 0:
print('https://www.reddit.com',n.permalink,sep='')
else:
print('https://www.reddit.com',n.permalink,i,sep='')
def go():
for save in reddit.redditor('accountUsername').saved(limit=None):
get(save,save,0)
go()
while read -r url; do
wget --convert-links --adjust-extension --page-requisites --no-parent --trust-server-names $url
done < redditSaved.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment