Debian Codegraph @

examples/forms/simple.py

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
•1 #!/usr/bin/env python3
2
3 from __future__ import print_function
4 import sys
5
6 from mechanize import Browser, urljoin, urlopen
7
8 if len(sys.argv) == 1:
9 uri = "http://wwwsearch.sourceforge.net/"
10 else:
11 uri = sys.argv[1]
12
13 br = Browser()
14 br.open(urljoin(uri, "mechanize/example.html"))
15 form = next(br.forms())
16 form = br.forms[0]
17 print(form)
18 form["comments"] = "Thanks, Gisle"
19 # form.click() returns a mechanize.Request object
20 # (see HTMLForm.click.__doc__ if you want to use only the forms support, and
21 # not the rest of mechanize)
22 print(urlopen(form.click()).read())