Skip to content

Instantly share code, notes, and snippets.

@kaveenr
Created July 30, 2016 19:12
Show Gist options
  • Save kaveenr/926fa861c63ddc1b6410946d22cd7385 to your computer and use it in GitHub Desktop.
Save kaveenr/926fa861c63ddc1b6410946d22cd7385 to your computer and use it in GitHub Desktop.
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