logging into secure website with script

James Stroud jstroud at ucla.edu
Tue Jan 24 21:33:12 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!
> 

Spend some time perusing this code:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302930

It helped me with a similar problem. I'm not sure if it works for https.

If the form is using POST to "hide" the login, just suck the web page 
and change POST to GET. Then use your sucked webpage and submit your 
login from it. You will then see the fields (separated by "+"s and the 
values, separated from the fields by "="s). Use the fields and values to 
populate the "txdata" dictionary in the example using urllib.urlencode 
(an example is in the discussion).

James



More information about the Python-list mailing list