Created
July 30, 2016 19:12
-
-
Save kaveenr/926fa861c63ddc1b6410946d22cd7385 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import urllib, urllib2, re, json, sys | |
count=0 | |
null = "" | |
ch= sys.argv[1] | |
print ch | |
true = True | |
false = False | |
imgur=[] | |
accp = ['.JPG','.PNG'] | |
try: | |
website = urllib.urlopen("http://www.reddit.com/r/"+ch+"/.json?count="+str(count)) | |
html=website.read() | |
jsonb = json.loads(html) | |
for i in jsonb['data']['children']: | |
imgur.append(i['data']['url']) | |
def down(i): | |
name = i.split("/") | |
urllib.urlretrieve(i,name[3]) | |
print "Downloaded "+ i | |
for i in imgur: | |
if i[(len(i)-4):(len(i))].upper() in accp: | |
down(i) | |
except: | |
print "Some shit Happened " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment