以下与我的问题相关的早期帖子都无法为我提供解决方案。所以我在一个新线程中发布。
我通过我大学中经过身份验证的代理连接到互联网。所以在浏览器中,我输入我的用户名密码。但是我无法在 python 中下载数据。
我在 python 2.7 中输入了以下 4 行来下载数据。我已经成功安装了 pandas 和 datetime 库;所以下面的前两行没有问题。
from pandas.io.data import DataReader
from datetime import datetime
goog = DataReader("GOOG", "yahoo", datetime(2000,1,1), datetime(2012,1,1))
print goog["Adj Close"]
我得到的错误如下:
Traceback (most recent call last):
File "C:\Program Files\Wing IDE 101 4.1\src\debug\tserver\_sandbox.py", line 3, in <module>
pass
File "C:\Python27\Lib\site-packages\pandas\io\data.py", line 53, in DataReader
return get_data_yahoo(name=name, start=start, end=end)
File "C:\Python27\Lib\site-packages\pandas\io\data.py", line 134, in get_data_yahoo
lines = urllib.urlopen(url).read()
File "C:\Python27\Lib\urllib.py", line 86, in urlopen
return opener.open(url)
File "C:\Python27\Lib\urllib.py", line 211, in open
return getattr(self, name)(url)
File "C:\Python27\Lib\urllib.py", line 344, in open_http
h.endheaders(data)
File "C:\Python27\Lib\httplib.py", line 954, in endheaders
self._send_output(message_body)
File "C:\Python27\Lib\httplib.py", line 814, in _send_output
self.send(msg)
File "C:\Python27\Lib\httplib.py", line 776, in send
self.connect()
File "C:\Python27\Lib\httplib.py", line 757, in connect
self.timeout, self.source_address)
File "C:\Python27\Lib\socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
IOError: [Errno socket error] [Errno 11004] getaddrinfo failed
有什么线索吗??