Fill In a Form Automatically

Victor Subervi victorsubervi at gmail.com
Fri Dec 7 15:06:23 EST 2007


Hi;
I'm trying to fill in a Zope form automatically. I have this script, which
works great for creating the page...but how do I write to it?

import urllib2

theurl = 'example.com'
protocol = 'http://'
my_id = "test"
text = "Hello, world!"
realm_dir = '/a_dir/'
realm1 = 'manage_addProduct/PageTemplates/manage_addPageTemplate?id=' +
my_id
realm2 = my_id
realm3 = my_id + '?content_type=text/html&title=testing'
username = 'name'
password = 'pass'
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, theurl, username, password)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)
pagehandle = urllib2.urlopen(protocol + theurl + realm_dir + realm1)
pagehandle.close()
pagehandle = urllib2.urlopen(protocol + theurl + realm_dir + realm2)
# data = pagehandle.write()
pagehandle.close()


TIA,
Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071207/b7751618/attachment.html>


More information about the Python-list mailing list