From 0d0932a4e212f2637e5ebb3296ff6e4fc6807f3a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 3 Mar 2010 13:37:37 -0700 Subject: [PATCH] Fix #5048 (ARS Technica fails) --- resources/recipes/ars_technica.recipe | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/resources/recipes/ars_technica.recipe b/resources/recipes/ars_technica.recipe index 0bf5a9a3b0..3997ee4645 100644 --- a/resources/recipes/ars_technica.recipe +++ b/resources/recipes/ars_technica.recipe @@ -5,6 +5,7 @@ __copyright__ = '2008-2010, Darko Miletic ' arstechnica.com ''' +import re from calibre.web.feeds.news import BasicNewsRecipe from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag @@ -20,7 +21,7 @@ class ArsTechnica2(BasicNewsRecipe): no_stylesheets = True encoding = 'utf-8' use_embedded_content = False - extra_css = ' body {font-family: sans-serif} .byline{font-weight: bold; line-height: 1em; font-size: 0.625em; text-decoration: none} ' + extra_css = ' body {font-family: Arial,Helvetica,sans-serif} .title{text-align: left} .byline{font-weight: bold; line-height: 1em; font-size: 0.625em; text-decoration: none} ' conversion_options = { 'comments' : description @@ -30,6 +31,10 @@ class ArsTechnica2(BasicNewsRecipe): } + preprocess_regexps = [ + (re.compile(r'
.*?', re.DOTALL|re.IGNORECASE),lambda match: '') + ] keep_only_tags = [dict(name='div', attrs={'id':['story','etc-story']})] @@ -37,7 +42,7 @@ class ArsTechnica2(BasicNewsRecipe): dict(name=['object','link','embed']) ,dict(name='div', attrs={'class':'read-more-link'}) ] - + remove_attributes=['width','height'] feeds = [ (u'Infinite Loop (Apple content)' , u'http://feeds.arstechnica.com/arstechnica/apple/' ) @@ -90,3 +95,5 @@ class ArsTechnica2(BasicNewsRecipe): return soup + def get_article_url(self, article): + return article.get('guid', None).rpartition('?')[0]