mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-11-22 22:43:02 -05:00
56 lines
2.2 KiB
Plaintext
56 lines
2.2 KiB
Plaintext
import re
|
|
from calibre.web.feeds.news import BasicNewsRecipe
|
|
|
|
|
|
class WashingtonPost(BasicNewsRecipe):
|
|
|
|
title = 'Washington Post'
|
|
description = 'US political news'
|
|
__author__ = 'Kovid Goyal and Sujata Raman'
|
|
use_embedded_content = False
|
|
max_articles_per_feed = 20
|
|
language = 'en'
|
|
|
|
|
|
remove_javascript = True
|
|
no_stylesheets = True
|
|
|
|
extra_css = '''
|
|
#articleCopyright { font-family:Arial,helvetica,sans-serif ; font-weight:bold ; font-size:x-small ;}
|
|
p { font-family:"Times New Roman",times,serif ; font-weight:normal ; font-size:small ;}
|
|
body{font-family:arial,helvetica,sans-serif}
|
|
'''
|
|
|
|
feeds = [ ('Today\'s Highlights', 'http://www.washingtonpost.com/wp-dyn/rss/linkset/2005/03/24/LI2005032400102.xml'),
|
|
('Politics', 'http://www.washingtonpost.com/wp-dyn/rss/politics/index.xml'),
|
|
('Nation', 'http://www.washingtonpost.com/wp-dyn/rss/nation/index.xml'),
|
|
('World', 'http://www.washingtonpost.com/wp-dyn/rss/world/index.xml'),
|
|
('Business', 'http://www.washingtonpost.com/wp-dyn/rss/business/index.xml'),
|
|
('Technology', 'http://www.washingtonpost.com/wp-dyn/rss/technology/index.xml'),
|
|
('Health', 'http://www.washingtonpost.com/wp-dyn/rss/health/index.xml'),
|
|
('Education', 'http://www.washingtonpost.com/wp-dyn/rss/education/index.xml'),
|
|
('Editorials', 'http://www.washingtonpost.com/wp-dyn/rss/linkset/2005/05/30/LI2005053000331.xml'),
|
|
]
|
|
|
|
remove_tags = [{'id':['pfmnav', 'ArticleCommentsWrapper']}]
|
|
|
|
|
|
def get_article_url(self, article):
|
|
return article.get('guid', article.get('link', None))
|
|
|
|
def print_version(self, url):
|
|
return url.rpartition('.')[0] + '_pf.html'
|
|
|
|
def postprocess_html(self, soup, first):
|
|
for div in soup.findAll(name='div', style=re.compile('margin')):
|
|
div['style'] = ''
|
|
return soup
|
|
|
|
def preprocess_html(self, soup):
|
|
for tag in soup.findAll('font'):
|
|
if tag.has_key('size'):
|
|
if tag['size'] == '+2':
|
|
if tag.b:
|
|
return soup
|
|
return None
|