mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
5df9807308
commit
b4b1c021f7
@ -3,7 +3,15 @@ __copyright__ = '2010, Walt Anthony <workshop.northpole at gmail.com>'
|
|||||||
'''
|
'''
|
||||||
www.americanthinker.com
|
www.americanthinker.com
|
||||||
'''
|
'''
|
||||||
|
import html5lib
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
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):
|
class AmericanThinker(BasicNewsRecipe):
|
||||||
title = u'American Thinker'
|
title = u'American Thinker'
|
||||||
@ -18,7 +26,7 @@ class AmericanThinker(BasicNewsRecipe):
|
|||||||
ignore_duplicate_articles = {'title', 'url'}
|
ignore_duplicate_articles = {'title', 'url'}
|
||||||
|
|
||||||
remove_javascript = True
|
remove_javascript = True
|
||||||
no_stylesheets = True
|
remove_tags_before = dict(name='h1')
|
||||||
|
|
||||||
conversion_options = {
|
conversion_options = {
|
||||||
'comment' : description
|
'comment' : description
|
||||||
@ -27,7 +35,14 @@ class AmericanThinker(BasicNewsRecipe):
|
|||||||
, 'language' : language
|
, 'language' : language
|
||||||
, 'linearize_tables' : True
|
, 'linearize_tables' : True
|
||||||
}
|
}
|
||||||
auto_claenup = 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'),
|
feeds = [(u'http://feeds.feedburner.com/americanthinker'),
|
||||||
(u'http://feeds.feedburner.com/AmericanThinkerBlog')
|
(u'http://feeds.feedburner.com/AmericanThinkerBlog')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user