From 984781777c9a6198fa6a5e19cb7cb79a003bf943 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Boulogne?= Date: Mon, 30 Sep 2013 13:46:33 +0200 Subject: [PATCH] post_process.redirect: Specify user-agent MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: François Boulogne Signed-off-by: W. Trevor King --- rss2email/post_process/redirect.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rss2email/post_process/redirect.py b/rss2email/post_process/redirect.py index 6ffd674..d06fcec 100644 --- a/rss2email/post_process/redirect.py +++ b/rss2email/post_process/redirect.py @@ -24,6 +24,7 @@ This hook finds and uses the real url behind redirects. import urllib import re +import rss2email def process(feed, parsed, entry, guid, message): # decode message @@ -37,7 +38,9 @@ def process(feed, parsed, entry, guid, message): # Remove the redirect and modify the content try: - direct_link = urllib.request.urlopen(link).geturl() + request = urllib.request.Request(link) + request.add_header('User-agent', rss2email.feed._USER_AGENT) + direct_link = urllib.request.urlopen(request).geturl() except: return message content = re.sub(re.escape(link), direct_link, content, re.MULTILINE) -- 2.26.2