Library to access xkcd.com
By Ben Rosser, released under MIT License (see LICENSE for full text).
This is a Python library for accessing and retrieving links to comics from the xkcd webcomic by Randall Munroe. It is NOT endorsed or made by him, it’s an entirely independent project.
It makes use of the JSON interface to Randall’s site to retrieve comic data. Both Python 2 and Python 3 are supported, and there are no dependencies beyond the Python standard library, so xkcd’s footprint should be very light.
There is support for accessing specific comics, the latest comic, or a random comic. Comic metadata can be queried and the comics themselves can be downloaded onto your local system. The goal is simply to provide a relatively Pythonic wrapper around the xkcd API for any Python program or library that wants to access information about xkcd comics, for one reason or another.
The xkcd module, as of version 2.4.0, also supports getting information on What If articles from whatif.xkcd.com. This information is generated by scraping the What If archive page with a HTML parser.
Full API documentation is available here.
Contributions from (github users, unless indicated otherwise):