[twill] Making a POST request without a form
Ryan van Roode
rvanroode at gmail.com
Wed Jul 4 23:17:05 PDT 2007
Great stuff, it works:
--
from twill import get_browser
from twill import commands as c
import urllib
b = get_browser()
# log in
b.go('http://www.blah.com/');
c.fv(1, 'username', 'test')
c.fv(1, 'password', 'test')
c.submit()
c.find('Welcome')
# now post a request without a form
mb = b._browser
data = urllib.urlencode({'some_var':'blah','another_var':'foo'})
r = mb.open("http://www.blah.com/postRequestHere/", data)
# print the response
print r.read()
--
I'm all set. Thanks for your help.
~rvr
On 7/5/07, Titus Brown <titus at caltech.edu> wrote:
> On Thu, Jul 05, 2007 at 09:40:45AM +0800, Ryan van Roode wrote:
> -> The next step is to figure out how to mix twill and mechanize commands
> -> in the same browser session. Thanks again.
>
> Ahh, now that should be easier ;). The command
>
> import twill
> b = twill.get_browser()
> mb = b._browser
>
> will get you a mechanize browser instance.
>
> --titus
>
More information about the twill
mailing list