2

I am trying to pull data from Quandl through Python. The problem I run into is that my Corporate's proxy blocks my ability to pull the data. Is there a way to log in to the proxy within the code itself by providing my username and password?

I am very new to Python/coding-in-general, and any help is greatly appreciated! I am using Python 3.5.

My code:

from Quandl import Quandl
mydata = Quandl.get("FRED/GDP")

Output:

URLError: <urlopen error Tunnel connection failed: 407 Proxy Authentication Required>
lchkng922
  • 23
  • 5

1 Answers1

2

Add the following lines to your code, to provide your proxy settings [1]:

import os

os.environ['HTTP_PROXY']  = "http://username:password@proxyAddress:portNumber"
os.environ['HTTPS_PROXY'] = "https://username:password@proxyAddress:portNumber"

After that, if you encounter the 465 certificate error you might choose to remove the ssl verification as follows [2]:

import ssl

ssl._create_default_https_context = ssl._create_unverified_context

For IPython, you might need to restart your kernel or reconnect to it for the changes to take effect.

You can check the current proxy settings with:

import urllib
urllib.request.getproxies_environment()

[1]. https://www.jayakumar.org/linux/how-to-configure-httphttps-proxy-for-ipython-notebook-server/ [2]. https://stackoverflow.com/a/28052583/4924665

Community
  • 1
  • 1
Yakzan
  • 71
  • 1
  • 6