This is a very simple example of httplib in Python. I am trying to write a very simple client which can simply ping a URL.
import httplib
while True:
myURL = raw_input('\nURL Please: \n> ')
if myURL == '':
print '\URL Please: \n'
break
httpconnection = httplib.HTTPConnection(myURL)
httpconnection.request('GET', '/')
res = httpconnection.getresponse()
#I am only interested in 200 OK response, anything else can be ignored
if res.status != 200:
print 'Errr!!!!', myURL, 'seems to be a troublesome URL. The "Internet" says "', res.reason, '" and the status was', res.status, '. Try again.'
else:
data = res.read()
allheaders = res.getheaders()
print data

















