From 8a841340d104d71aff7c5fdccdb70b01134a7d4f Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Mon, 13 Jan 2014 13:34:46 +0100 Subject: requests is now too using the defined proxy. --- pyaggr3g470r/feedgetter.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyaggr3g470r/feedgetter.py b/pyaggr3g470r/feedgetter.py index 0926aa99..eee9ea2b 100644 --- a/pyaggr3g470r/feedgetter.py +++ b/pyaggr3g470r/feedgetter.py @@ -64,9 +64,14 @@ class FeedGetter(object): feedparser.USER_AGENT = conf.USER_AGENT if conf.HTTP_PROXY == "": self.proxy = urllib2.ProxyHandler({}) + self.proxies = {} else: self.proxy = urllib2.ProxyHandler({"http" : conf.HTTP_PROXY, \ "https": conf.HTTP_PROXY}) + self.proxies = { + "http": "http://" + conf.HTTP_PROXY, + "https": "http://" + conf.HTTP_PROXY + } feedparser.USER_AGENT = conf.USER_AGENT self.user = models.User.objects(email=email).first() @@ -105,7 +110,7 @@ class FeedGetter(object): nice_url = article.link.encode("utf-8") try: # resolves URL behind proxies (like feedproxy.google.com) - r = requests.get(article.link, timeout=2.0) + r = requests.get(article.link, timeout=2.0, proxies=self.proxies) nice_url = r.url.encode("utf-8") except Timeout: pyaggr3g470r_log.warning("Timeout when getting the real URL of %s." % (article.link,)) -- cgit