2

I'm posting this because I tried searching for the answer myself and I was not able to find a solution. I was eventually able to figure out a way to get this to work & I hope this helps someone else in the future.

Scenario:

In Windows XP, I'm using Python with Pandas & Quandl to get data for a US Equity security using the following line of code:

bars = Quandl.get("GOOG/NYSE_SPY", collapse="daily")

Unfortunately, I was getting the following error:

urllib2.URLError: <urlopen error [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond>

@user3150079: kindly Ctrl+X / Ctrl+V your solution as an [Answer]. Such MOV is perfectly within StackOverflow

Solution:

I recognized that this was an issue with trying to contact a server without properly targeting my network's proxy server. Since I was not able to set the system variable for HTTP_PROXY, I added the following line which corrected the issue:

import os
os.environ['HTTP_PROXY']="10.11.123.456:8080"

Thanks - I'm interested to hear about any improvements to this solution or other suggestions.

user3666197
  • 1
  • 6
  • 50
  • 92
user3150079
  • 459
  • 4
  • 6
  • You should really post the answer as an answer rather than within the question – EdChum Oct 03 '14 at 18:53
  • It would probably be better if you only had the question in the question, then posted an answer to that with your solution. [Some](http://meta.stackexchange.com/questions/17463/can-i-answer-my-own-questions-even-if-i-knew-the-answer-before-asking) [relevant](http://meta.stackexchange.com/questions/97877/should-i-ask-questions-intended-to-be-self-answered) [links](http://stackoverflow.com/help/self-answer). – Roger Fan Oct 03 '14 at 18:54
  • Thanks for the feedback. I updated the title to be more clear and next time I will use the "Answer Your Question" feature. – user3150079 Oct 14 '14 at 14:17

2 Answers2

0

You can set your user environment variable HTTP_PROXY if you can't or won't set the system environment variable:

set HTTP_PROXY "10.11.123.456:8080"
python yourscript.py

and to permanently set it (using setx from Windows XP Service Pack 2 Support Tools):

setx HTTP_PROXY "10.11.123.456:8080"
python yourscript.py

Other ways to get this environment variable set include: registry entries, putting os.environ["HTTP_PROXY"] = ..." insitecustomize.py`.

mtd
  • 2,224
  • 19
  • 21
0

More control using requests without using the Quandl Package:

import requests

    def main():
        proxies = {'http': 'http://proxy.yourdomain.com:port',
                   'https': 'http://proxy.yourdomain.com:port',}

        url =  'https://www.quandl.com/api/v3/datasets/GOOG/NYSE_SPY.json?collapse=daily'

        response = requests.get(url, proxies=proxies)

        status = response.status_code
        html_text = response.text
        repo_data = response.json()

        print(repo_data)

        print(status)

        print('HTML TEXT')
        print('=========')
        print(html_text)

if __name__ == '__main__':
    main() 
ctrl-alt-delete
  • 3,696
  • 2
  • 24
  • 37