我今天在尝试通过发送“ GET” HTTP请求来检索XML时遇到错误。
from httplib import HTTPConnection
import urllib
params = urllib.urlencode({'sK': 'test', 'sXML': 1})
httpCon = HTTPConnection("http://www.podnapisi.net",80)
httpCon.request('GET', '/en/ppodnapisi/search',params)
r1 = httpCon.getresponse()
这是我得到的错误:
.....
File "C:\Python27\lib\socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 11004] getaddrinfo failed
我试图检索的XML HERE
如何解决此错误?
提前致谢 ...
最佳答案
HTTPConnection构造函数中没有方案(http://
):
httpCon = HTTPConnection("www.podnapisi.net",80)
它已经知道它是HTTP,这是一个HTTPConnection对象:)
关于python - python中的HTTPConnection请求socket.gaierror,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9019134/