IOError:[Errno套接字错误] [Errno 11004] getaddrinfo在可访问的地址上失败

时间:2013-04-24 08:09:47

标签: python getaddrinfo

我可以在浏览器中打开网址:http://www.bloomberg.com/markets/chart/data/1M/AAPL:AR 但我的代码出现了结果:I/O error(socket error):[Errno 11004] getaddrinfo failed

import urllib
import json
url='http://www.bloomberg.com/markets/chart/data/1M/AAPL:AR'
try:
    html_file=urllib.urlopen(url)
    html_text=html_file.read()
    data=json.load(html_text)
    data_points=data['data_values']
    for i in range(len(data_points)):
        print data_points[i]
except IOError as (errno,strerror):
    print "I/O error({0}):{1}".format(errno,strerror)

0 个答案:

没有答案