Last active
April 6, 2017 13:58
-
-
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!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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