1

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`

1 Answer 1

3

Try this

import httplib
conn = httplib.HTTPConnection("10.1.1.19", 80)
conn.request("GET", "http://www.python.org/index.html", headers={...}))
Sign up to request clarification or add additional context in comments.

2 Comments

i have tried this ;but response string from server says "bad request".
hey working now ,might the server be down at last time;THANXX.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.