我正在尝试向" www.python.org"发送一个基本的获取请求。获取" www.python.org/index.html"在python中使用httplib模块。我使用代理服务器" 10.1.1.19:80"。我的代码显示错误信息。请告诉我错误我提交.Regards .. ..
>>> import httplib
>>> conn=httplib.HTTPConnection("http://www.python.org",80)
>>> conn.set_tunnel("10.1.1.19:80")
>>> conn.request("GET","www.python.org/index.html",headers={"Proxy-Authorization":"Basic "+"MzEwNTMzOmdveWFs"})
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
conn.request("GET","www.python.org/index.html",headers={"Proxy-Authorization":"Basic "+"MzEwNTMzOmdveWFs"})
File "C:\Python27\lib\httplib.py", line 973, in request
self._send_request(method, url, body, headers)
File "C:\Python27\lib\httplib.py", line 1007, in _send_request
self.endheaders(body)
File "C:\Python27\lib\httplib.py", line 969, in endheaders
self._send_output(message_body)
File "C:\Python27\lib\httplib.py", line 829, in _send_output
self.send(msg)
File "C:\Python27\lib\httplib.py", line 791, in send
self.connect()
File "C:\Python27\lib\httplib.py", line 772, 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):
gaierror: [Errno 11004] getaddrinfo failed`
答案 0 :(得分:3)
试试这个
import httplib
conn = httplib.HTTPConnection("10.1.1.19", 80)
conn.request("GET", "http://www.python.org/index.html", headers={...}))