This notebook was planned to get comments data from some user on Reddit. Yet, it is not able to proceed with request without providing an agent name (as the default wrapper is overwhelmed). So we defined it and put it into a dictionary called headers as an argument to requests.get function. The Reddit API JSON response can be publicly accessed as presented on the 2nd code line.
In [1]:
import requests
In [2]:
data = requests.get(r'http://www.reddit.com/user/narek/comments/.json',headers = {'User-agent': 'Educational bot'})
In [4]:
data = data.json()
In [5]:
from pprint import pprint
pprint(data)
In [6]:
for child in data['data']['children']:
print child['data']['id'], " ", child['data']['author'],child['data']['body']
print