>>> import requests
>>> from pprint import pprint
>>> r = requests.get('http://www.reddit.com/reddits.json', headers= {'User-Agent': 'me'})
>>> data = r.json()
>>> pprint(data.keys())
This prints subreddits & im trying to figure out how much it prints out or if I can print out a certain number. Thanks !
import requests
r = requests.get('http://www.reddit.com/reddits.json', headers= {'User-Agent': 'me'})
data = r.json()
print(len(data['data']['children']))
The structure of the JSON is complicated, so I'm not entirely sure what you are trying to count, but ['data']['children']
appears to be the root of the subreddits.