https://www.imooc.com/video/10682

urllib2

url = "http://www.baidu.com"

urllib2.urlopen(url)

print response1.getcode()

print response1.read()

request = urllib2.Request(url)

request.add_header("user-agent","Mozilla/5.0")

response2 = urllib2.urlopen(request)

print response2.getcode()

print response2.read()

cj = cookielib.CookieJar()

opener = urllib2.build_opener(urllib2.HttpCookieProcessor(cj))

urllib2.install_openner(opener)

response3 = urllib2.urlopen(url)

print response3.getcode()

print response3.read()