저는 초보자 python prorammer입니다. 2.7.2, Windows 7, 내장 인터프리터 및 3 개의 라이브러리. 나는 오류와 함께 이것을하려고 노력하고있다. 어떤 도움을 주셔서 감사합니다?IOError : [Errno socket error] [오류 11004] getaddrinfo가 실패했습니다.
import os
import urllib
import socket
DISNEY_URL = 'http://www.sec.gov/Archives/edgar/data/1001039/000119312511321340/dis-20111001.xml'
#Neither of these seem to work when opening with urllib.urlopen becaue of the error:
#I/O error(socket error): [Errno 11004] getaddrinfo failed
DISNEY_LOCAL = 'file://C:/Users/Nate/Desktop/Education/python_education/xbrlnexusfiles/xbrlfiles/dis-20111001.xml'
DISNEY_LOCAL_NONE = 'file://C:/Users/Nate/Desktop/Education/python_education/xbrlnexusfiles/xbrlfiles/dis.txt'
class SECFilingPackage(object):
def __init__ (self, SEC_URL):
URLFilePath, URLFileExt = os.path.splitext(SEC_URL)
try:
urllib.urlopen(SEC_URL)
except IOError as (errno, strerror):
print "I/O error({0}): {1}".format(errno, strerror)
#This error throws, see it copied above;
DisneyPackage = SECFilingPackage(DISNEY_LOCAL_NONE)
는이 오류를 얻을 : I/O 오류 (소켓 오류) :
는[Errno 11004] getaddrinfo failed
예 텍스트 파일이 해당 위치에 존재한다. 텍스트 파일의 내용은 "아무것도"
스택 추적 마지막 호출이 open_ftp
C:/Python27/Lib/urllib.py
에 라인 (516) 였다고 없습니다 :
host = socket.gethostbyname(host)
IOError: [Errno socket error] [Errno 11004] getaddrinfo failed
내가 잘 URL을 열 수, 그래서 그것이 proxy/firewall issue 생각하지 않습니다 (나는 그 사실을 정말로 이해하지 못한다)
그리고 나는 무엇을 newlines or ENDs과 관련이 있는지 모른다.
나는 그것 때문에의 작동합니다 믿는 urllib reference:
If the URL does not have a scheme identifier, or if it has file: as its scheme identifier, this opens a local file (without universal newlines); otherwise it opens a socket to a server somewhere on the network.
(I이 그냥 보편적 인 개행 문자가 이미 변환 기대하고 누군가가 실망 할 것입니다 의미 생각합니다.
참고 나는 또한에 대한 부분 이의를 제기 내가 file://
로 문자열을 선행하지 않으면 때문에, "그것은 체계 식별자가없는 경우"나는 얻을
IOError: [Errno url error] unknown url type: 'c')
"물고기를 배우는 법"을 말하고 싶습니다. 누군가 적어도이 값들을 이해하기 위해서 urllib.py
에 디버깅 할 수있는 방법이 있다고 말할 수 있습니까? 이클립스로 할 수 있을까요? 항상 나를 강제로 프로젝트로 만드는 것 같습니다.
http://stackoverflow.com/questions/5022945/urllib2-urlerror-urlopen-error-errno-11004-getaddrinfo-failed – jdi