雅虎财经api抛出404。urllib2.HTTPError:HTTP错误400:错误请求

2024-05-09 02:18:59 发布

您现在位置:Python中文网/ 问答频道 /正文

$ pip install yahoo-finance
$ python

然后在python控制台中

^{pr2}$

Traceback (most recent call last): File "", line 1, in File "/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/init.py", line 178, in init self.refresh() File "/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/init.py", line 142, in refresh self.data_set = self._fetch() File "/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/init.py", line 181, in _fetch data = super(Share, self)._fetch() File "/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/init.py", line 134, in _fetch data = self._request(query) File "/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/init.py", line 118, in _request response = yql.YQLQuery().execute(query) File "/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/yql.py", line 61, in execute 'env': DATATABLES_URL File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in 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", line 435, in open 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, in http_response 'http', request, response, code, msg, hdrs) File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 473, in error 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, in _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", line 556, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 400: Bad Request


Tags: inpyinitlibpackageslinesiteurllib2