Menu
  • HOME
  • TAGS

python keyError at JSON parsing

python,json,google-books

You can use the dict.get() method to retrieve a default, or you can use membership testing to see if the key is there at all: for book in response.get('items', []): if 'title' not in book['volumeInfo'] or 'authors' not in book['volumeInfo']: continue print 'Title: %s, Author: %s' % (book['volumeInfo']['title'], book['volumeInfo']['authors']) ...

Google Books API Cover images over HTTPS fails due to certificate error

google-api,google-books

Remove the sub-sub-domain, or the encryption: This is an encrypted version of the image at https://books.google.com, and This is an unencrypted version at http://bk1.books.google.com Their certificate covers wildcard.google.com but not wildcard.wildcard.google.com. Just speculating I'd guess that bks1 is one of a pool of servers behind books....

Parsing JSON with Jackson return null

java,json,parsing,jersey-client,google-books

You need to model the full JSON structure, something like this: public class BookData { String kind; Integer totalItems; List<Item> items; } public class Item { String kind; String id; //... Volume volumeInfo; } Then you can use ObjectMapper to read the BookData: BookData bookData = new ObjectMapper().readValue(output, BookData.class); And...

List chapters of a book from a public books API?

web-services,api,rest,amazon-web-services,google-books

You might want to have a look at the Open Librayr API: https://openlibrary.org/dev/docs/api/books The jscmd=details query parameter might be of use for you, since it returns a table of contents....