Fix Globe and Mail

This commit is contained in:
Kovid Goyal 2011-01-12 18:59:41 -07:00
parent f0881c3d26
commit d0f92778f8

View File

@ -8,12 +8,13 @@ __docformat__ = 'restructuredtext en'
globeandmail.com globeandmail.com
''' '''
import re
from calibre.web.feeds.news import BasicNewsRecipe from calibre.web.feeds.news import BasicNewsRecipe
class AdvancedUserRecipe1287083651(BasicNewsRecipe): class AdvancedUserRecipe1287083651(BasicNewsRecipe):
title = u'Globe & Mail' title = u'Globe & Mail'
__license__ = 'GPL v3' __author__ = 'Kovid Goyal'
__author__ = 'Szing'
oldest_article = 2 oldest_article = 2
no_stylesheets = True no_stylesheets = True
max_articles_per_feed = 100 max_articles_per_feed = 100
@ -38,24 +39,19 @@ class AdvancedUserRecipe1287083651(BasicNewsRecipe):
(u'Sports', u'http://www.theglobeandmail.com/auto/?service=rss') (u'Sports', u'http://www.theglobeandmail.com/auto/?service=rss')
] ]
keep_only_tags = [ preprocess_regexps = [
dict(name='h1'), (re.compile(r'<head.*?</head>', re.DOTALL), lambda m: '<head></head>'),
dict(name='h2', attrs={'id':'articletitle'}), (re.compile(r'<script.*?</script>', re.DOTALL), lambda m: ''),
dict(name='p', attrs={'class':['leadText', 'meta', 'leadImage', 'redtext byline', 'bodyText']}), ]
dict(name='div', attrs={'class':['news','articlemeta','articlecopy']}),
dict(name='id', attrs={'class':'article'}),
dict(name='table', attrs={'class':'todays-market'}),
dict(name='header', attrs={'id':'leadheader'})
]
remove_tags_before = dict(name='h1')
remove_tags = [ remove_tags = [
dict(name='div', attrs={'id':['tabInside', 'ShareArticles', 'topStories']}) dict(name='div', attrs={'id':['ShareArticles', 'topStories']}),
] dict(href=lambda x: x and 'tracking=' in x),
{'class':['articleTools', 'pagination', 'Ads', 'topad',
#this has to be here or the text in the article appears twice. 'breadcrumbs', 'footerNav', 'footerUtil', 'downloadlinks']}]
remove_tags_after = [dict(id='article')]
#Use the mobile version rather than the web version #Use the mobile version rather than the web version
def print_version(self, url): def print_version(self, url):
return url + '&service=mobile' return url.rpartition('?')[0] + '?service=mobile'