View Single Post
Old 05-04-2018, 11:24 AM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,438
Karma: 27757438
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I took a quick look, and this is what I came up with:

Code:
def classes(classes):
    q = frozenset(classes.split(' '))
    return dict(
        attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)}
    )


class AdvancedUserRecipe1502348373(BasicNewsRecipe):
    title = 'The Federalist'
    oldest_article = 7
    max_articles_per_feed = 100
    no_stylesheets = True
    encoding = 'utf-8'
    use_embedded_content = False
    remove_attributes = ['xmlns', 'lang', 'style', 'width', 'height']

    keep_only_tags = [
        classes('entry-header'),
        classes('wp-post-image post-categories entry-content shortbio'),
    ]

    feeds = [
        ('All', 'http://thefederalist.com/feed/'),
    ]
kovidgoyal is offline   Reply With Quote