Cor*_*erg 14
看看机械化."在Python中进行有状态的程序化Web浏览".
它自动处理cookie.
import mechanize
br = mechanize.Browser()
resp = br.open("http://www.mysitewithcookies.com/")
print resp.info() # headers
print resp.read() # content
Run Code Online (Sandbox Code Playgroud)
mechanize还公开了urllib2 API,默认情况下启用了cookie处理.