Getting a cookie

Alan Gauld alan.gauld at gssec.bt.co.uk
Wed Oct 4 13:01:32 EDT 2000


> "Set-Cookie".  I could print the header (hdrs) to STDOUT, by
> using
> 
> print hdrs
> ...
> because I can't not search through it or anything.  If I use
> the line,
> 
> for x in hdrs:
>     print x
> 
> it gives me the error

This is probably a rotten solution but I think it will work...
print is presumably using the repr() function of the hdrs 
object. Thus you should be able to assign  that to a string:

hdrstr = `hdrs`

Now split the hdr into lines using string.split()

hdrlst = string.split(hdrstr)

now iterate over hdrl;st:

for x in hdrldst:
   if re.match('Cookie:', x):
      # cookie = x[n:] where n is the appropriate position...

Worth a try?

alan G.
-- 
=================================================
This post represents the views of the author 
and does not necessarily accurately represent 
the views of BT.



More information about the Python-list mailing list