import urllib2

try:
response = urllib2.urlopen('http://www.baidu.com')
except urllib2.URLError, e:
print e.reason print response.read()
05-11 22:42