logging into secure website with script

Fuzzyman fuzzyman at gmail.com
Wed Jan 25 07:59:47 EST 2006

dpoehls wrote:
> Hello there,
> I am new to python, and shell scriping in general..I have done quite a
> bit of php, but that it about it. Anyhow, I am wondering if it would be
> possible to write a python script that would login to a password
> enabled site (qmailadmin) and then be able to add a new account.  I
> imagine it could be done by accessing the website and then it would
> send POSTs to the website?  If this makes no sense, I apologize, just
> wondering if anyone could point me in the right direction. Thanks ahead
> of time!

You should use urllib2 to fetch URLs. See :


urllib2 will also allow you to do POST.

How you handle the password depends on whether it is by a form, or by
basic authentication. For basic authentication see :


If it is through a form, you can use ClientForm. Alternatively just
manually do the POST from urllib2. You may want to use
ClientCookie/cookielib for (automatic) cookie handling :


All the best,


More information about the Python-list mailing list