mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix Washington Post
This commit is contained in:
parent
3de3f3d4fb
commit
517a3e3975
@ -1,4 +1,3 @@
|
|||||||
import re
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
|
|
||||||
@ -6,55 +5,48 @@ class WashingtonPost(BasicNewsRecipe):
|
|||||||
|
|
||||||
title = 'Washington Post'
|
title = 'Washington Post'
|
||||||
description = 'US political news'
|
description = 'US political news'
|
||||||
__author__ = 'Kovid Goyal and Sujata Raman'
|
__author__ = 'Kovid Goyal'
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
max_articles_per_feed = 20
|
max_articles_per_feed = 20
|
||||||
language = 'en'
|
language = 'en'
|
||||||
|
encoding = 'utf-8'
|
||||||
|
|
||||||
|
|
||||||
remove_javascript = True
|
remove_javascript = True
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
|
|
||||||
extra_css = '''
|
feeds = [
|
||||||
#articleCopyright { font-family:Arial,helvetica,sans-serif ; font-weight:bold ; font-size:x-small ;}
|
('Politics', 'http://www.washingtonpost.com/rss/politics'),
|
||||||
p { font-family:"Times New Roman",times,serif ; font-weight:normal ; font-size:small ;}
|
('Nation', 'http://www.washingtonpost.com/rss/national'),
|
||||||
body{font-family:arial,helvetica,sans-serif}
|
('World', 'http://www.washingtonpost.com/rss/world'),
|
||||||
'''
|
('Business', 'http://www.washingtonpost.com/rss/business'),
|
||||||
|
('Lifestyle', 'http://www.washingtonpost.com/rss/lifestyle'),
|
||||||
feeds = [ ('Today\'s Highlights', 'http://www.washingtonpost.com/wp-dyn/rss/linkset/2005/03/24/LI2005032400102.xml'),
|
('Sports', 'http://www.washingtonpost.com/rss/sports'),
|
||||||
('Politics', 'http://www.washingtonpost.com/wp-dyn/rss/politics/index.xml'),
|
('Redskins', 'http://www.washingtonpost.com/rss/sports/redskins'),
|
||||||
('Nation', 'http://www.washingtonpost.com/wp-dyn/rss/nation/index.xml'),
|
('Opinions', 'http://www.washingtonpost.com/rss/opinions'),
|
||||||
('World', 'http://www.washingtonpost.com/wp-dyn/rss/world/index.xml'),
|
('Entertainment', 'http://www.washingtonpost.com/rss/entertainment'),
|
||||||
('Business', 'http://www.washingtonpost.com/wp-dyn/rss/business/index.xml'),
|
('Local', 'http://www.washingtonpost.com/rss/local'),
|
||||||
('Technology', 'http://www.washingtonpost.com/wp-dyn/rss/technology/index.xml'),
|
('Investigations',
|
||||||
('Health', 'http://www.washingtonpost.com/wp-dyn/rss/health/index.xml'),
|
'http://www.washingtonpost.com/rss/investigations'),
|
||||||
('Education', 'http://www.washingtonpost.com/wp-dyn/rss/education/index.xml'),
|
|
||||||
('Style',
|
|
||||||
'http://www.washingtonpost.com/wp-dyn/rss/print/style/index.xml'),
|
|
||||||
('NFL Sports',
|
|
||||||
'http://www.washingtonpost.com/wp-dyn/rss/sports/index/nfl/index.xml'),
|
|
||||||
('Redskins', 'http://www.washingtonpost.com/wp-dyn/rss/sports/redskins/index.xml'),
|
|
||||||
('Editorials', 'http://www.washingtonpost.com/wp-dyn/rss/linkset/2005/05/30/LI2005053000331.xml'),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
remove_tags = [{'id':['pfmnav', 'ArticleCommentsWrapper']}]
|
remove_tags = [
|
||||||
|
{'class':lambda x: x and 'article-toolbar' in x},
|
||||||
|
{'class':lambda x: x and 'quick-comments' in x},
|
||||||
|
{'class':lambda x: x and 'tweet' in x},
|
||||||
|
{'class':lambda x: x and 'article-related' in x},
|
||||||
|
{'class':lambda x: x and 'hidden' in x.split()},
|
||||||
|
{'class':lambda x: x and 'also-read' in x.split()},
|
||||||
|
{'class':lambda x: x and 'partners-content' in x.split()},
|
||||||
|
{'class':['module share', 'module ads', 'comment-vars', 'hidden',
|
||||||
|
'share-icons-wrap', 'comments']},
|
||||||
|
{'id':['right-rail']},
|
||||||
|
|
||||||
|
]
|
||||||
|
keep_only_tags = dict(id=['content', 'article'])
|
||||||
|
|
||||||
def get_article_url(self, article):
|
|
||||||
return article.get('guid', article.get('link', None))
|
|
||||||
|
|
||||||
def print_version(self, url):
|
def print_version(self, url):
|
||||||
return url.rpartition('.')[0] + '_pf.html'
|
url = url.rpartition('?')[0]
|
||||||
|
return url.replace('_story.html', '_singlePage.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
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user