From 1a2814494e1f5aa6e79a593b8bd5ccca6fdea099 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 11 Apr 2015 18:46:16 +0530 Subject: [PATCH] Resolve internal links for The Economist --- recipes/economist.recipe | 6 ++++++ recipes/economist_free.recipe | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/recipes/economist.recipe b/recipes/economist.recipe index 18e6eb4185..c2baecd58b 100644 --- a/recipes/economist.recipe +++ b/recipes/economist.recipe @@ -41,6 +41,7 @@ class Economist(BasicNewsRecipe): } ''' oldest_article = 7.0 + resolve_internal_links = True remove_tags = [ dict(name=['script', 'noscript', 'title', 'iframe', 'cf_floatingcontent']), dict(attrs={'class':['dblClkTrk', 'ec-article-info', @@ -150,3 +151,8 @@ class Economist(BasicNewsRecipe): div.insert(2, img) table.replaceWith(div) return soup + + def canonicalize_internal_url(self, url, is_link=True): + if url.endswith('/print'): + url = url.rpartition('/')[0] + return BasicNewsRecipe.canonicalize_internal_url(self, url, is_link=is_link) diff --git a/recipes/economist_free.recipe b/recipes/economist_free.recipe index 412a860c28..8034873f8d 100644 --- a/recipes/economist_free.recipe +++ b/recipes/economist_free.recipe @@ -41,6 +41,7 @@ class Economist(BasicNewsRecipe): } ''' oldest_article = 7.0 + resolve_internal_links = True remove_tags = [ dict(name=['script', 'noscript', 'title', 'iframe', 'cf_floatingcontent']), dict(attrs={'class':['dblClkTrk', 'ec-article-info', @@ -149,3 +150,8 @@ class Economist(BasicNewsRecipe): div.insert(2, img) table.replaceWith(div) return soup + + def canonicalize_internal_url(self, url, is_link=True): + if url.endswith('/print'): + url = url.rpartition('/')[0] + return BasicNewsRecipe.canonicalize_internal_url(self, url, is_link=is_link)