Python 将Mechanize设置为接受cookie

Python 将Mechanize设置为接受cookie,python,mechanize,Python,Mechanize,我正在尝试使用mechanize从网站检索一些数据,以自动搜索公寓(无垃圾邮件) 但是,当我向站点发送请求时,响应具有以下标题: header: Cache-Control: no-store, no-cache, max-age=0, must-revalidate, private, max- stale=0, post-check=0, pre-check=0 header: Content-Type: text/html header: P3P: CP="ALL IND DSP

我正在尝试使用mechanize从网站检索一些数据,以自动搜索公寓(无垃圾邮件)

但是,当我向站点发送请求时,响应具有以下标题:

header: Cache-Control: no-store, no-cache, max-age=0, must-revalidate, private,  max-     stale=0, post-check=0, pre-check=0
header: Content-Type: text/html
header: P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
header: Date: Mon, 16 Jun 2014 19:13:23 GMT
header: Connection: close
header: Set-Cookie: SPSI=1f5cf9461ca8ab1ee7f4d427ce1c895b ; path=/
header: Content-Length: 10965
回复文本中的内容大致是“您必须启用Cookie” 我如何用mechanize模拟它? 这样做似乎不起作用:

br = mechanize.Browser()
# Cookie Jar
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)

仅供参考,我已经机械化了0.2.5。如果这不起作用,我正在考虑硒。

我也有同样的问题。添加这些浏览器选项。从这里开始:

我还建议使用调试消息

 # Want debugging messages?
 #br.set_debug_http(True)
 #br.set_debug_redirects(True)
 #br.set_debug_responses(True)
 # Want debugging messages?
 #br.set_debug_http(True)
 #br.set_debug_redirects(True)
 #br.set_debug_responses(True)