#__author__ = 'DouYunQian'

#coding=utf-8

import urllib2

url="https://www.baidu.com/s"

print u"第一种方法",type(u"第一种方法"),type("第一种方法")

response=urllib2.urlopen(url)

print response.getcode()

print len(response.read())

print "第二种方法"

request=urllib2.Request(url)

request.add_header("User-Agent","Mozilla/5.0")

request.add_data("{wd:'welcome'}")

response=urllib2.urlopen(request)

print response.code

print len(response.read())





print "第三种方法"

import cookielib

ck=cookielib.CookieJar()

opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(ck))

urllib2.install_opener(opener)

response=urllib2.urlopen(url)

print response.getcode()



print len(response.read())