Log-in to forums (using cookielib)?

Olivier Oost nomail at gmail.com
Tue May 1 03:44:57 EDT 2007


Hi,

I need to login to a online forum, like a phpbb forum, and leave a 
message there. I figured I need to use cookielib, but the documentation 
of cookielib is not very clear to me.

I tried to just copy/paste all the cookies from FireFox into my 
Python-program, like this:
import cookielib, urllib2, urllib
cookiejar=cookielib.CookieJar()
urlOpener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
values={'__utmb':'1234', 'mybbuser':'1234_1234', '__utmz':'1234', 
'sid':'1234', '__utma':'1234'}
data=urllib.urlencode(values)
request=urllib2.Request("http://ep2.nl",data)
url=urlOpener.open(request)
page=url.read(1024000)

Can someone please tell me how I should log-in and leave a message on 
the board?



More information about the Python-list mailing list