In [42]:
import requests
In [61]:
# mother's day in 2010
response = requests.get("http://api.nytimes.com/svc/books/v2/lists/hardcover-fiction.json?bestsellers-date=2010-05-04&rank=20&api-key=a6019bd075824e40941fd84de1e3de28")
data = response.json()
In [62]:
type(data)
Out[62]:
In [63]:
data.keys()
Out[63]:
In [64]:
type(data['results'])
Out[64]:
In [65]:
data['results'][0]['book_details'][0]['title']
Out[65]:
In [56]:
# mother's day in 2010
for result in data['results']:
for title in result['book_details']:
print (title['title'])
In [66]:
# mother's day in 2009
response = requests.get("http://api.nytimes.com/svc/books/v2/lists/hardcover-fiction.json?bestsellers-date=2009-05-04&rank=20&api-key=a6019bd075824e40941fd84de1e3de28")
data = response.json()
In [67]:
# mother's day in 2009
for result in data['results']:
for title in result['book_details']:
print (title['title'])
In [85]:
# June 6, 2009
response = requests.get("http://api.nytimes.com/svc/books/v2/lists/names.json?bestsellers-date=2009-06-06&api-key=a6019bd075824e40941fd84de1e3de28")
data = response.json()
In [86]:
data.keys()
Out[86]:
In [89]:
data['results'][0]['list_name']
Out[89]:
In [90]:
# June 6, 2009
for categories in data['results']:
print (categories['list_name'])
In [91]:
# June 6, 2015
response = requests.get("http://api.nytimes.com/svc/books/v2/lists/names.json?bestsellers-date=2015-06-06&api-key=a6019bd075824e40941fd84de1e3de28")
data = response.json()
In [92]:
# June 6, 2015
for categories in data['results']:
print (categories['list_name'])
In [ ]: