urllib error in Sage running on a Mac

asked 2017-06-02 20:22:29 -0600

markus gravatar image

I have used urllib in Sage for a while now (on Mac OS Yosemite). However, recently I've been getting an error: [Errno url error] unknown url type: 'https'

The code I'm using is getting exchange rates from Yahoo.

import urllib
def getRate(sym):
    url = 'http://finance.yahoo.com/d/quotes.csv?s=%s&f=%s' % (sym, 'l1c1va2xj1b4j4dyekjm3m4rr5p5p6s7')
    values = urllib.urlopen(url).read().strip().strip('"').split(',')
    return float(str(values[0]))

sym="EUR=X"
getRate(sym)
edit retag flag offensive close merge delete