$ pip install yahoo-finance
$ python
然后在python控制台中,
>>> from yahoo_finance import Share
>>> yahoo = Share('YHOO')
回溯(最近一次呼叫最后一次):文件"",第1行,在文件中 " /Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/的初始化的.py&#34 ;, 第178行,在 init 中 self.refresh()File" /Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/ init .py", 第142行,刷新 self.data_set = self._fetch()File" /Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/ init .py", 第181行,在_fetch中 data = super(Share,self)._ fetch()File" /Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/ init .py&#34 ;, 第134行,在_fetch中 data = self._request(query)File" /Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/ init .py", 第118行,在_request response = yql.YQLQuery()。execute(query)File" /Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/yql.py", 第61行,执行中 ' env':DATATABLES_URL文件" /usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py" ,第154行,在urlopen return opener.open(url,data,timeout)File" /usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py" ;,第435行,公开 response = meth(req,response)File" /usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py" ;, line 548,在http_response中 ' http',请求,响应,代码,消息,hdrs)文件" /usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2 .7 / urllib2.py",第473行,错误 return self._call_chain(* args)File" /usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py" ;, line 407,在_call_chain中 result = func(* args)File" /usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py" ;,第556行,在http_error_default中 引发HTTPError(req.get_full_url(),代码,msg,hdrs,fp)urllib2.HTTPError:HTTP错误400:错误请求