More than one cookie with urllib2

Rafael T. Ugolini rafael at vexbr.com.br
Thu Dec 11 16:05:43 EST 2003


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)

nebula:/home/nebuloso#  nc -l -p 80
POST / HTTP/1.0
Host: localhost
User-agent: Python-urllib/2.1
Cookie: JSESSIONID=DFA58D39389BA5E3CEB5C92F9308792C
Content-length: 34
Content-type: application/x-www-form-urlencoded
                                                                                                                                              
j_username=psyca&j_password=******

---
and another thing , headers is a dic , you cant add 2 equal keys...
dunno how to do it.

Thanks.






More information about the Python-list mailing list