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):
|
def openLibrary(isbn):
|
||||||
jsondata = urlopen("http://openlibrary.org/api/books?format=json&jscmd=data&bibkeys=ISBN:"+isbn)
|
jsondata = urlopen("http://openlibrary.org/api/books?format=json&jscmd=data&bibkeys=ISBN:"+isbn)
|
||||||
book = load(jsondata)
|
openBook = load(jsondata)
|
||||||
if len(book)==0:
|
if "ISBN:"+isbn not in openBook:
|
||||||
return book
|
return openBook
|
||||||
else:
|
openBook = openBook["ISBN:"+isbn]
|
||||||
return book["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")
|
book = openLibrary("9780521714723")
|
||||||
if "title" in book: print book["title"]
|
print dumps(book, indent=2)
|
||||||
if "subjects" in book: print dumps(book["subjects"], indent=2)
|
|
||||||
book = openLibrary("9780521565431")
|
book = openLibrary("9780521565431")
|
||||||
if "title" in book: print book["title"]
|
print dumps(book, indent=2)
|
||||||
if "subjects" in book: print dumps(book["subjects"], indent=2)
|
|
||||||
book = openLibrary("689145728392")
|
book = openLibrary("689145728392")
|
||||||
if "title" in book: print book["title"]
|
print dumps(book, indent=2)
|
||||||
if "subjects" in book: print dumps(book["subjects"], indent=2)
|
|
||||||
book = openLibrary("9780321468932")
|
book = openLibrary("9780321468932")
|
||||||
if "title" in book: print book["title"]
|
print dumps(book, indent=2)
|
||||||
if "subjects" in book: print dumps(book["subjects"], indent=2)
|
|
||||||
book = openLibrary("9781555580414")
|
book = openLibrary("9781555580414")
|
||||||
if "title" in book: print book["title"]
|
print dumps(book, indent=2)
|
||||||
if "subjects" in book: print dumps(book["subjects"], indent=2)
|
|
||||||
|
|
Loading…
Reference in New Issue