Question

i am trying to send a basic get request to "www.python.org" to fetch "www.python.org/index.html" using the httplib module in python.I use a proxy server "10.1.1.19:80".My code with the error message is shown.Please suggest me with the mistakes i'm commiting.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`
Was it helpful?

Solution

Try this

import httplib
conn = httplib.HTTPConnection("10.1.1.19", 80)
conn.request("GET", "http://www.python.org/index.html", headers={...}))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top