I am trying to connect to websites with Python and get the HTTP status codes. As answers on this other question of mine suggest, the reason that HTTP status code for websites such as google.com are 301 or 302 (permanently moved) is that these servers are redirecting. However, I would like to be able to connect to them in such a manner that I get the natural 200 (OK) from them. Here's my current code:
import httplib
conn = httplib.HTTPConnection("google.com", 80)
conn.request("GET","/")
r = conn.getresponse()
print r.status, r.reason
conn.close()
What do I need to alter/add to achieve this? I heard that pycurl
library might help me with that, but googling hasn't brought any useful results so far. I am a novice in this field, so please excuse me if the question is trivial.