How to get Http Response using Python – 1

Today I am starting new series of posts for python and interesting things that can be done with it.

The following code can be used to hit the url and print the response in python

#You can use the Python standard libraries urllib, urllib2 or httplib to make HTTP requests

import urllib2

#the method urlopen hits the url specified and read method returns the response

response = urllib2.urlopen(‘http://www.facebook.com’).read()

print response

Thanks

J.K.B.S

Advertisements