I’ve been using http://goodreads.com for several years and have good substantial list of books on my To Read shelf. I thought it would be interesting to see how hard using the GoodReads API would be.

Not too difficult.

First I registered with GoodReads to get an API key. Then I ran the following curl command.

export GDKEY=XXX
curl --silent \
  -o goodreads-to-read.xml \

I created a small python script to handle reading the XML.

import xml.etree.ElementTree as etree
tree = etree.parse('/usr/src/app/goodreads-to-read.xml')
root = tree.getroot()
for child in root:
    if child.tag == 'reviews':
        for review in child:
            for reviewElements in review:
                if reviewElements.tag == 'book':
                    for bookElements in reviewElements:
                        if bookElements.tag == 'title':

The last step runs the script:

docker run \
  --rm=true \
  -v $(pwd):/usr/src/app \
  python:3.6.3 \
  python /usr/src/app/parsexml.py | head | sort

You could use python directly, of course, if you have it already installed.