started creation of book info format
This commit is contained in:
parent
b7cc88f4bd
commit
6591fc2de0
28
bookData.py
28
bookData.py
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue