From: François Boulogne Date: Mon, 30 Sep 2013 11:46:33 +0000 (+0200) Subject: post_process.redirect: Specify user-agent X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=984781777c9a6198fa6a5e19cb7cb79a003bf943;p=rss2email.git post_process.redirect: Specify user-agent Signed-off-by: François Boulogne Signed-off-by: W. Trevor King --- 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)