Re: More than one cookie with urllib2
From: John J. Lee (jjl_at_pobox.com)
Date: 12/12/03
- Next message: Guyon Morée: "Re: HalfLife/Cstrike monitorring"
- Previous message: Brett C.: "python-dev Summary for 2003-11-16 through 2003-11-30"
- In reply to: Rafael T. Ugolini: "More than one cookie with urllib2"
- Next in thread: Peter Hansen: "Re: More than one cookie with urllib2"
- Reply: Peter Hansen: "Re: More than one cookie with urllib2"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 11 Dec 2003 23:09:49 +0000
"Rafael T. Ugolini" <rafael@vexbr.com.br> writes:
> Im trying to add more than one cookie with urllib2 but im not getting
> much sucess.
> An example...
>
>
> >>> req =
> urllib2.Request('http://localhost','j_username=psyca&j_password=******',{
> 'Cookie':'sab=contextUrl+https%3A%2F%2Fwwws.vexbr.com.br%2Fcafedev%2F%7CnasIp+10.50.0.3%7CneedCheckCode+false%7ClocationId+85%7CautoLogout+false%7CserviceProviderId+1%7CorigUrl+%2Findex.html%7CwebContext+cafedev%7CclientIp+192.168.1.107%7CnasId+vex_cafedev%7CloginType+0%7Cclass+class+com.wificom.sab.aaa.dto.SessionDTO%7CloginResumed+false%7CloggedIn+false%7Clanguage+en%7CpricingPlanId+0%7CsslPort+443%7CroamingPriceId+0%7CclientMac+00%3A07%3A95%3AD3%3A0C%3A7C%7CserverUrl+https%3A%2F%2Fwwws.vexbr.com.br%2F',
> 'Cookie':'JSESSIONID=DFA58D39389BA5E3CEB5C92F9308792C',
> 'Content-type':'application/x-www-form-urlencoded',
> 'Content-length':str(len('j_username=psyca&j_password=******'))})
> >>> urllib2.urlopen(req)
[...]
Blech.
> and another thing , headers is a dic , you cant add 2 equal keys...
> dunno how to do it.
[...]
If you want to stay sane, use this:
http://wwwsearch.sourceforge.net/ClientCookie
just say:
ClientCookie.urlopen(req)
and forget about cookies. If you insist on doing it by hand, though:
you need to join your key=value pairs with semicolons:
Cookie: foo=bar; spam=eggs
John
- Next message: Guyon Morée: "Re: HalfLife/Cstrike monitorring"
- Previous message: Brett C.: "python-dev Summary for 2003-11-16 through 2003-11-30"
- In reply to: Rafael T. Ugolini: "More than one cookie with urllib2"
- Next in thread: Peter Hansen: "Re: More than one cookie with urllib2"
- Reply: Peter Hansen: "Re: More than one cookie with urllib2"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]