started creation of book info format
[library/.git] / bookData.py
1 from urllib2 import urlopen
2 from json import load,dumps
3
4 def openLibrary(isbn):
5     jsondata = urlopen("http://openlibrary.org/api/books?format=json&jscmd=data&bibkeys=ISBN:"+isbn)
6     openBook = load(jsondata)
7     if "ISBN:"+isbn not in openBook:
8         return openBook
9     openBook = openBook["ISBN:"+isbn]
10     # create my custom dict for books with the info we want.
11     book = {"isbn" : isbn}
12     book['title']=openbook['title']
13     # continue with the rest later
14
15 book = openLibrary("9780521714723")
16 print dumps(book, indent=2)
17 book = openLibrary("9780521565431")
18 print dumps(book, indent=2)
19 book = openLibrary("689145728392")
20 print dumps(book, indent=2)
21 book = openLibrary("9780321468932")
22 print dumps(book, indent=2)
23 book = openLibrary("9781555580414")
24 print dumps(book, indent=2)