update to tornado 4.0 and requests 2.3.0

This commit is contained in:
j 2014-08-12 10:44:01 +02:00
commit f187000dc9
239 changed files with 19071 additions and 20369 deletions

View file

@ -6,3 +6,27 @@ def find(query):
print url
data = json.loads(read_url(url))
return data
def authors_ol(authors):
r = []
for a in authors:
url = 'http://openlibrary.org%s.json' % a
data = json.loads(read_url(url))
r.append(data['name'])
return r
def get_data(isbn):
data = {}
ol = find(isbn)
if ol['docs']:
d = ol['docs'][0]
data['title'] = d['title']
data['author'] = authors_ol(d['authors'])
data['work'] = d['key']
data['edition'] = d['edition_key'][0]
url = 'https://openlibrary.org/books/%s.json' % data['edition']
info = json.load(read_url(url))
data['pages'] = info['number_of_pages']
if 'dewey_decimal_class' in info:
data['classification'] = info['dewey_decimal_class'][0]
return data