Problem with ClientCookie

Levente Sandor sandorlevi at yahoo.com
Fri Sep 27 22:11:58 CEST 2002


Probably the error is caused by the "secure" word in the set-cookie
headers, because it doesn't contain "=", so it cannot be split by
re.split(r"\s*=\s*", param, 1).
I never used the ClientCookie package, but you may try to replace line
627 in the source with the following one:
if '=' in param: k, v = re.split(r"\s*=\s*", param, 1)
(be sure to retain the original indentation of the line)
----
levi

"Rob Hall" <bloke at ii.net> wrote in message news:<3d946d0f$0$10364 at echo-01.iinet.net.au>...
> I am trying to use ClientCookie to access a HTTPS website under Win98.  I
> have installed the W32 SSL wrappers.
> 
> The code I have is similar to as follows (have removed authorisation
> detail):
> 
> import urllib
> import ClientCookie
> 
> if __name__ == '__main__':
>     urllib.URLopener.version = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows
> NT 5.0)'
>     print 'Logging on...'
>     request =
> urllib2.Request('https://www.quicktrade.com.au/cgi-bin/login?USERNAME=myUser
> Name&PASSWORD=myPassword')
>     result = ClientCookie.urlopen(request)
> 
> I have set HTTP_DEBUG = 1 in _ClientCookie.py
> 
> I get the following response...
> 
> 
> Logging on...
> Page requested...
> send: 'GET /cgi-bin/login?USERNAME=myUserName&PASSWORD=myPassword
> HTTP/1.0\r\n'
> send: 'Host: www.quicktrade.com.au\r\n'
> send: 'User-agent: Python-urllib/2.0a1\r\n'
> send: '\r\n'
> reply: 'HTTP/1.1 200 OK\r\n'
> header: Date: Fri, 27 Sep 2002 14:21:31 GMT
> 
> header: Server: Stronghold/2.4.2 Apache/1.3.6 C2NetEU/2410 (Unix)
> 
> header: set-cookie:
> key=Kpfz5sbkkPrwsM7eng5ihtfuKq6sAlSdwTXhn/jUiEOSOCYJAC5r/Vlq+5uS9wqkpHJzOWHi
> m4v+^Va7SldrYP9Vqea2vDKtZWnOiP7Ff5ckrrM61DDM+tIGO44jUyKPt2yof5Uz7lvUu0ErVqJk
> DWAYX^7x66TxqZ2esB823pOue6zNxcmhY1SiS7pPTd5w3X/5ncX3njMZs_^; Path=/; secure
> header: set-cookie: acct=myUserName STGBNET; Path=/; secure
> header: set-cookie: level=1; Path=/; Domain=.quicktrade.com.au; secure
> header: set-cookie: ID=1802009989; Path=/; Domain=.quicktrade.com.au; secure
> header: set-cookie: w1=None; Path=/; secure
> header: P3P: CP="NON DSP ADMa OUR IND UNI FIN"
> header: Connection: close
> header: Content-Type: text/html
> 
> Traceback (most recent call last):
>   File
> "C:\WINDOWS\Desktop\backup\uni\project\development\htmlProcessor\htmlProcess
> or.py", line 22, in ?
>     result = ClientCookie.urlopen(request)
>   File "C:\PYTHON22\lib\site-packages\ClientCookie\_ClientCookie.py", line
> 1387, in urlopen
>     return _opener.open(url, data)
>   File "C:\PYTHON22\lib\urllib2.py", line 322, in open
>     '_open', req)
>   File "C:\PYTHON22\lib\urllib2.py", line 301, in _call_chain
>     result = func(*args)
>   File "C:\PYTHON22\lib\site-packages\ClientCookie\_ClientCookie.py", line
> 1334, in https_open
>     return self.do_open(httplib.HTTPS, req)
>   File "C:\PYTHON22\lib\site-packages\ClientCookie\_ClientCookie.py", line
> 1319, in do_open
>     self.c.extract_cookies(result, req, redirect=redirect)
>   File "C:\PYTHON22\lib\site-packages\ClientCookie\_ClientCookie.py", line
> 627, in extract_cookies
>     k, v = re.split(r"\s*=\s*", param, 1)
> ValueError: unpack list of wrong size
> 
> I can't find anything to help me debug this.  Is the error because the web
> server is returning more than one cookie?  or is it just returning a bad
> format?
> 
> Any help is greatly appreciated.
> 
> Rob



More information about the Python-list mailing list