Fix Wired Daily

This commit is contained in:
Kovid Goyal 2011-01-12 10:35:05 -07:00
parent 80b736d4e1
commit d7ea545df6

View File

@ -2,8 +2,10 @@
__license__ = 'GPL v3' __license__ = 'GPL v3'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import re
from calibre.web.feeds.news import BasicNewsRecipe from calibre.web.feeds.news import BasicNewsRecipe
from calibre.ebooks.chardet import xml_to_unicode
class Wired_Daily(BasicNewsRecipe): class Wired_Daily(BasicNewsRecipe):
@ -15,30 +17,43 @@ class Wired_Daily(BasicNewsRecipe):
no_stylesheets = True no_stylesheets = True
preprocess_regexps = [(re.compile(r'<head.*</head>', re.DOTALL), lambda m:
'<head></head>')]
remove_tags_before = dict(name='div', id='content') remove_tags_before = dict(name='div', id='content')
remove_tags = [dict(id=['social_tools', 'outerWrapper', 'sidebar', remove_tags = [dict(id=['header', 'commenting_module', 'post_nav',
'footer', 'advertisement', 'blog_subscription_unit', 'social_tools', 'sidebar', 'footer', 'social_wishlist', 'pgwidget',
'brightcove_component']), 'outerWrapper', 'inf_widget']),
{'class':'entryActions'}, {'class':['entryActions', 'advertisement', 'entryTags']},
dict(name=['noscript', 'script'])] dict(name=['noscript', 'script']),
dict(name='h4', attrs={'class':re.compile(r'rat\d+')}),
{'class':lambda x: x and x.startswith('contentjump')},
dict(name='li', attrs={'class':['entryCategories', 'entryEdit']})]
feeds = [ feeds = [
('Top News', 'http://feeds.wired.com/wired/index'), ('Top News', 'http://feeds.wired.com/wired/index'),
('Culture', 'http://feeds.wired.com/wired/culture'), ('Product Reviews',
('Software', 'http://feeds.wired.com/wired/software'), 'http://www.wired.com/reviews/feeds/latestProductsRss'),
('Mac', 'http://feeds.feedburner.com/cultofmac/bFow'), ('Autopia', 'http://www.wired.com/autopia/feed/'),
('Gadgets', 'http://feeds.wired.com/wired/gadgets'), ('Danger Room', 'http://www.wired.com/dangerroom/feed/'),
('Cars', 'http://feeds.wired.com/wired/cars'), ('Epicenter', 'http://www.wired.com/epicenter/feed/'),
('Entertainment', 'http://feeds.wired.com/wired/entertainment'), ('Gadget Lab', 'http://www.wired.com/gadgetlab/feed/'),
('Gaming', 'http://feeds.wired.com/wired/gaming'), ('Geek Dad', 'http://www.wired.com/geekdad/feed/'),
('Science', 'http://feeds.wired.com/wired/science'), ('Playbook', 'http://www.wired.com/playbook/feed/'),
('Med Tech', 'http://feeds.wired.com/wired/medtech'), ('Rawfile', 'http://www.wired.com/rawfile/feed/'),
('Politics', 'http://feeds.wired.com/wired/politics'), ('This Day in Tech', 'http://www.wired.com/thisdayintech/feed/'),
('Tech Biz', 'http://feeds.wired.com/wired/techbiz'), ('Threat Level', 'http://www.wired.com/threatlevel/feed/'),
('Commentary', 'http://feeds.wired.com/wired/commentary'), ('Underwire', 'http://www.wired.com/underwire/feed/'),
('Web Monkey', 'http://www.webmonkey.com/feed/'),
('Science', 'http://www.wired.com/wiredscience/feed/'),
] ]
def populate_article_metadata(self, article, soup, first):
if article.text_summary:
article.text_summary = xml_to_unicode(article.text_summary,
resolve_entities=True)[0]
def print_version(self, url): def print_version(self, url):
return url.replace('http://www.wired.com/', 'http://www.wired.com/print/') return url + '/all/1'