Multi-Page login WITH Cookies (POST Data)

Pyro pyro.699 at gmail.com
Thu May 17 19:36:39 EDT 2007


 Before i go into some detail i would like to start off by saying that this
is NOT an advertising bot or anything like that.

I am a web programmer designing a website in PHP and it requires users to
login. I am building a program that will login as the administrator and
browse the forums looking for any inappropriate activity. Here is how i have
my login setup (it needs to be setup like this).

http://pyro.allblizz.com/python/login1.php (Just Username) (username =
'thisname')
http://pyro.allblizz.com/python/login2.php (Just Password) (password =
'whatpassword')
http://pyro.allblizz.com/python/home.php (Home)
(links are valid, and working submit system)

Now, without cookies (just POST data) I am able to get this to work.

[code]
#!/usr/bin/python
import sys
from urllib2 import urlopen
from ClientForm import ParseResponse
forms = ParseResponse(urlopen("http://pyro.allblizz.com/login1.php"))[0]
forms["username"] = "thisname"
forms2 = ParseResponse(urlopen(forms.click()))[0]
forms2["password"] = "whatpassword"
print urlopen(forms2.click()).read()
[/code]

If you go and fill out the username and passwords using a web browser, you
are able to login but, when i use this code it does not work. (Because the
cookies are not being stored)

After we are able to get a succussful login, i need a way that i can browse
my site always including this cookie, like if i went to open up a page, it
would use the cookie we got from logging in.

Thanks alot guys
~Cody
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070517/84953ebb/attachment.html>


More information about the Python-list mailing list