[twill] website login using twill and python

Terry Peppers peppers at gmail.com
Wed Sep 5 12:07:23 PDT 2007


Mohammed -

The command you're using to set the password is incorrect.

This -> fv("2", "pass", "password")

Should be -> > fv("1", "pass", "password")

Here's my example session:

---- START SNIP ----

[terryp at Macintosh] terryp :: python
Python 2.4.4 (#1, Oct 18 2006, 10:34:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from twill.commands import *
>>> go("http://www.crimebloc.com")
==> at http://www.crimebloc.com
'http://www.crimebloc.com'
>>> showforms()

Form name=login (#1)
## ## __Name__________________ __Type___ __ID________ __Value__________________
1     login                    text      (None)
2     pass                     password  (None)
3     enhanced                 checkbox  enhanced     ['enhanced'] of
['enhanced']
4  1  sublogin                 submit    (None)        Login

<generator object at 0x7c31c0>
>>> fv(1, "login", "some_login")
>>> fv(1, "pass", "some_password")
>>> showforms()

Form name=login (#1)
## ## __Name__________________ __Type___ __ID________ __Value__________________
1     login                    text      (None)       some_login
2     pass                     password  (None)       some_password
3     enhanced                 checkbox  enhanced     ['enhanced'] of
['enhanced']
4  1  sublogin                 submit    (None)        Login

<generator object at 0x13b03f0>
>>>

---- END SNIP ----

Obviously in these two lines you'll want to substitute your
credentials instead of "some_login" and "some_password."

>>> fv(1, "login", "some_login")
>>> fv(1, "pass", "some_password")

Hope this helps.

t.



More information about the twill mailing list