求助cookie问题
#!/usr/bin/env python# -- coding:gbk --
import sys, time, os, re
import urllib, urllib2, cookielib
loginurl = 'https://auth.'
#loginurl = 'https://www.'
cookie = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie))
urllib2.install_opener(opener)
params = {
'username' : 'XXX',
'password' : 'XXX',
'lt' : '_c573C07C4-AD13-CD25-85E9-CC917AF0433F_k42B35CAA-C2E7-7B2C-A7A1-9FD4E6CBE30F',
'_eventId' : 'submit'
}
req = urllib2.Request(loginurl,urllib.urlencode(params))
res = urllib2.urlopen(req).read()
m = re.search(r'\s+(.+?)\s+',str(cookie))
jsession=re.sub(r'\s+', '', m.group(0))
#print jsession
header={'Cookie':jsession}
#response=opener.open(req).read()
req1 = urllib2.Request(loginurl,urllib.urlencode(params),header)
res1 = urllib2.urlopen(req1)
print res1.geturl()
response1=opener.open(res1.geturl())
print response1.read()
不知道这段代码哪里出了问题,就是登不进去