started creation of book info format

This commit is contained in:
John Ladan 2012-03-11 03:40:14 -04:00
parent b7cc88f4bd
commit 6591fc2de0
1 changed files with 13 additions and 15 deletions

View File

@ -3,24 +3,22 @@ from json import load,dumps
def openLibrary(isbn):
jsondata = urlopen("http://openlibrary.org/api/books?format=json&jscmd=data&bibkeys=ISBN:"+isbn)
book = load(jsondata)
if len(book)==0:
return book
else:
return book["ISBN:"+isbn]
openBook = load(jsondata)
if "ISBN:"+isbn not in openBook:
return openBook
openBook = openBook["ISBN:"+isbn]
# create my custom dict for books with the info we want.
book = {"isbn" : isbn}
book['title']=openbook['title']
# continue with the rest later
book = openLibrary("9780521714723")
if "title" in book: print book["title"]
if "subjects" in book: print dumps(book["subjects"], indent=2)
print dumps(book, indent=2)
book = openLibrary("9780521565431")
if "title" in book: print book["title"]
if "subjects" in book: print dumps(book["subjects"], indent=2)
print dumps(book, indent=2)
book = openLibrary("689145728392")
if "title" in book: print book["title"]
if "subjects" in book: print dumps(book["subjects"], indent=2)
print dumps(book, indent=2)
book = openLibrary("9780321468932")
if "title" in book: print book["title"]
if "subjects" in book: print dumps(book["subjects"], indent=2)
print dumps(book, indent=2)
book = openLibrary("9781555580414")
if "title" in book: print book["title"]
if "subjects" in book: print dumps(book["subjects"], indent=2)
print dumps(book, indent=2)