Read xkcd on your iPad or Kindle in no time. Click download to load the free ebook on your reader.

Check out all the available public recipes or write your own with these quick start guides. ReadBeam is built on calibre, so everything in the docs and the fora applies here as well.

Download for free »

xkcd is a webcomic created by Randall Munroe. The comic's tagline describes it as "a webcomic of romance, sarcasm, math, and language.

Language: en

Requires Subscription: No, it's available as free ebook

Schedule Every morning

			  __license__   = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
'''
Changelog:
2011-09-24
Changed cover (drMerry)
'''
'''
Fetch xkcd.
'''

import time, re
from calibre.web.feeds.news import BasicNewsRecipe

class XkcdCom(BasicNewsRecipe):
    cover_url = 'http://imgs.xkcd.com/s/9be30a7.png'
    title = 'xkcd'
    description = 'A webcomic of romance and math humor.'
    __author__ = 'Martin Pitt updated by DrMerry.'
    language = 'en'

    use_embedded_content   = False
    oldest_article = 60
    keep_only_tags = [dict(id='middleContent')]
    remove_tags = [dict(name='ul'), dict(name='h3'), dict(name='br')]
    no_stylesheets = True
    # turn image bubblehelp into a paragraph
    preprocess_regexps = [
        (re.compile(r'(<img.*title=")([^"]+)(".*>)'),
         lambda m: '%s%s<p>%s</p>' % (m.group(1), m.group(3), m.group(2)))
    ]

    def parse_index(self):
        INDEX = 'http://xkcd.com/archive/'

        soup = self.index_to_soup(INDEX)
        articles = []
        for item in soup.findAll('a', title=True):
            articles.append({
                'date': item['title'],
                'timestamp': time.mktime(time.strptime(item['title'], '%Y-%m-%d'))+1,
                'url': 'http://xkcd.com' + item['href'],
                'title': self.tag_to_string(item),
                'description': '',
                'content': '',
            })

        return [('xkcd', articles)]