diff options
author | Cédric Bonhomme <kimble.mandel@gmail.com> | 2014-01-13 13:34:46 +0100 |
---|---|---|
committer | Cédric Bonhomme <kimble.mandel@gmail.com> | 2014-01-13 13:34:46 +0100 |
commit | 8a841340d104d71aff7c5fdccdb70b01134a7d4f (patch) | |
tree | 8d7422499166c8dee71922654e63800e72587a61 | |
parent | Feedgetter now uses the defined proxy of HTTP and HTTPS. (diff) | |
download | newspipe-8a841340d104d71aff7c5fdccdb70b01134a7d4f.tar.gz newspipe-8a841340d104d71aff7c5fdccdb70b01134a7d4f.tar.bz2 newspipe-8a841340d104d71aff7c5fdccdb70b01134a7d4f.zip |
requests is now too using the defined proxy.
-rw-r--r-- | pyaggr3g470r/feedgetter.py | 7 |
1 files changed, 6 insertions, 1 deletions
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,)) |