python获取cookies

import urllib2
import cookielib
cookie = cookielib.CookieJar()
handler=urllib2.HTTPCookieProcessor(cookie)
opener = urllib2.build_opener(handler)
response = opener.open('http://www.baidu.com')
for item in cookie:
    # print 'Name = '+item.name
    # print 'Value = '+item.value
    print(item)

 

转载于:https://www.cnblogs.com/linbinqiang/p/4902745.html

你可能感兴趣的:(python)