Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 03-13-2013, 11:18 AM   #1
kinsnik
Junior Member
kinsnik began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Mar 2013
Device: Kindle 4 (nt)
What If...

I had problems with the feed of what-if.xkcd.com, because the images were not there. So i decided to make my own What If recipe. I added the text below the images.

Code:
import  re
from calibre.web.feeds.news import BasicNewsRecipe

class XkcdCom(BasicNewsRecipe):
    cover_url =    'http://what-if.xkcd.com/imgs/whatif-logo.png'
    masthead_url = 'http://what-if.xkcd.com/imgs/whatif-logo.png'
    title = 'What If...'
    description = 'What If...'
    language = 'en'
    keep_only_tags = [dict(name='article')]

    use_embedded_content   = False
    oldest_article = 60
    # add image and text
   # add an horizontal line after the question
    preprocess_regexps = [
        (re.compile(r'(<img.*title=")([^"]+)(".*>)'),
         lambda m: '<div>%s%s<p id="photo_text">(%s)</p></div>' % (m.group(1), m.group(3), m.group(2))),
        (re.compile(r'(<p.*id="attribute">[^>]+</p>)'),
         lambda n: '%s<hr>' % (n.group(1))),
    ]

    extra_css = "#photo_text{font-size:small;}"

    feeds          = [(u'What If...', u'http://what-if.xkcd.com/feed.atom')]
Feel free to make any changes you want
kinsnik is offline   Reply With Quote
Reply


Forum Jump


All times are GMT -4. The time now is 06:32 AM.


MobileRead.com is a privately owned, operated and funded community.