By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,818 Members | 1,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,818 IT Pros & Developers. It's quick & easy.

Log-in to forums (using cookielib)?

P: n/a
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.HTTPCookieP rocessor(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?
May 1 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
En Tue, 01 May 2007 04:44:57 -0300, Olivier Oost <no****@gmail.com>
escribió:
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.
Can someone please tell me how I should log-in and leave a message on
the board?
Sure. But considering that this smells like an Automatic Spamming Machine,
I hope nobody will.

--
Gabriel Genellina
May 1 '07 #2

P: n/a
Gabriel Genellina wrote:
En Tue, 01 May 2007 04:44:57 -0300, Olivier Oost <no****@gmail.com>
escribió:
>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.
Can someone please tell me how I should log-in and leave a message on
the board?

Sure. But considering that this smells like an Automatic Spamming
Machine, I hope nobody will.

--Gabriel Genellina
No, it's not meant as a spamming machine. I only need to post a message
and then (if that's possible) lock the topic (I'm admin on the forum
where I need this). The program first needs to read the topic for
certain words (that's already working), and then reply that those words
aren't welcome.

I hope I made myself clear.
May 1 '07 #3

P: n/a
En Tue, 01 May 2007 05:39:14 -0300, Olivier Oost <no****@gmail.com>
escribió:
Gabriel Genellina wrote:
>En Tue, 01 May 2007 04:44:57 -0300, Olivier Oost <no****@gmail.com>
escribió:
>>Can someone please tell me how I should log-in and leave a message on
the board?
Sure. But considering that this smells like an Automatic Spamming
Machine, I hope nobody will.
No, it's not meant as a spamming machine. I only need to post a message
and then (if that's possible) lock the topic (I'm admin on the forum
where I need this). The program first needs to read the topic for
certain words (that's already working), and then reply that those words
aren't welcome.
I would verify that in the forum code if possible, not remotely.
Anyway, the examples at the end of the cookielib section in the library
reference are what you need: create an OpenerDirector using
urllib2.build_opener, adding a suitable HTTPCookieProcessor handler.

--
Gabriel Genellina
May 1 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.