[Tutor] Web client in Python
Alexandre Ratti
alex@gabuzomeu.net
Wed, 29 May 2002 18:44:09 +0200
Hi Kevin,
At 12:00 29/05/2002 -0400, you wrote:
>From: "Kevin Christy" <kevinchristy@socal.rr.com>
>Subject: RE: [Tutor] Web client in Python
>Date: Wed, 29 May 2002 06:44:21 -0700
>
>Thanks to all who responded. I will post the code once it gets the job
>done; I am not getting successful logins, perhaps because of the cookie
>issue. The HTTP server is generating a hidden, temporary session ID code
>that may be the problem.
If the site uses cookies to store the temporary session ID, these resources
might be useful:
1) "Cookie Spy": it's a free Internet Explorer plug-in that displays cookie
values while browsing. It helped me work around a similar login issue. I
don't have a URL, but the developer is called Konstantin Boukreev
(konstantin@mail.primorye.ru).
2) "clientcookie": this is a Python module. From my snippets:
<QUOTE>
Clientcookie is a Python module for handling cookies on the client side,
useful for accessing web sites that require cookies to be set, and returned
later. It is a port of Gisle Aas' Perl module HTTP::Cookies, from the
libwww-perl library. Both RFC2965 and Netscape cookies are supported.
import ClientCookie
import urllib2
request = urllib2.Request("http://www.acme.com/")
# note we're using the urlopen from ClientCookie, not urllib2
result = ClientCookie.urlopen(request)
# let's say this next request requires a cookie that was set in result
request2 = urllib2.Request("http://www.acme.com/flying_machines.html")
result2 = ClientCookie.urlopen(request2)
http://wwwsearch.sourceforge.net/ClientCookie
</QUOTE>
Cheers.
Alexandre