import mechanize
br = mechanize.Browser()
br.open('http://pypi.python.org/pypi')
br.select_form('searchform')
br['term'] = 'Mechanize'
response = br.submit()
Filling textarea with Python mechanize module