calibre/recipes/american_thinker.recipe
Kovid Goyal b4b1c021f7 ...
2014-03-09 10:16:21 +05:30

53 lines
1.9 KiB
Plaintext

__license__ = 'GPL v3'
__copyright__ = '2010, Walt Anthony <workshop.northpole at gmail.com>'
'''
www.americanthinker.com
'''
import html5lib
from calibre.web.feeds.news import BasicNewsRecipe
from calibre.utils.cleantext import clean_xml_chars
from lxml import etree
def CSSSelect(expr):
from cssselect import HTMLTranslator
from lxml.etree import XPath
return XPath(HTMLTranslator().css_to_xpath(expr))
class AmericanThinker(BasicNewsRecipe):
title = u'American Thinker'
description = "American Thinker is a daily internet publication devoted to the thoughtful exploration of issues of importance to Americans."
__author__ = 'Walt Anthony'
publisher = 'Thomas Lifson'
category = 'news, politics, USA'
oldest_article = 7 # days
max_articles_per_feed = 50
summary_length = 150
language = 'en'
ignore_duplicate_articles = {'title', 'url'}
remove_javascript = True
remove_tags_before = dict(name='h1')
conversion_options = {
'comment' : description
, 'tags' : category
, 'publisher' : publisher
, 'language' : language
, 'linearize_tables' : True
}
def preprocess_raw_html(self, raw, url):
root = html5lib.parse(
clean_xml_chars(raw), treebuilder='lxml',
namespaceHTMLElements=False)
for x in CSSSelect('.article_body.bottom')(root):
x.getparent().remove(x)
return etree.tostring(root, encoding=unicode)
feeds = [(u'http://feeds.feedburner.com/americanthinker'),
(u'http://feeds.feedburner.com/AmericanThinkerBlog')
]
def print_version(self, url):
return 'http://www.americanthinker.com/assets/3rd_party/printpage/?url=' + url