Projects/pensieve
Projects
/
pensieve
Archived
3
0
Fork 0
This repository has been archived on 2024-08-06. You can view files and clone it, but cannot push or open issues or pull requests.
pensieve/pensieve.py

29 lines
674 B
Python
Raw Normal View History

#!/usr/bin/python
from os import system
import json
import urllib2
import time
def load_json(subreddit):
2013-10-17 14:51:39 +02:00
req = urllib2.urlopen('http://www.reddit.com/r/' + subreddit + '.json?limit=1000')
json_string = json.load(req)
return json_string[u'data'][u'children']
def add_urls_to_list(subreddit):
obj = load_json(subreddit)
img_urls = []
for a in obj:
if a[u'data'][u'domain'] == u'i.imgur.com':
img_urls.append( a[u'data'][u'url'])
return img_urls
def load_subreddit():
f = open('subreddit', 'r')
subreddit = f.readline().strip()
f.close()
return subreddit
urls = add_urls_to_list(load_subreddit())
2013-10-17 14:51:39 +02:00
print urls