ANN: mechanize 0.0.1a released
John J. Lee
23 Dec 2003 14:52:53 +0000
This is the initial alpha release. In terms of features, it's pretty
complete already. It seems to work pretty well, and there's a working
example in the tarball. The base class of mechanize.Browser,
mechanize.UserAgent is a bit dodgy, though.
Requires Python 2.2, ClientCookie 0.4.12 (note version!), ClientForm
0.1.x and pullparser 0.2.b.
Stateful programmatic web browsing, after Andy Lester's Perl module
from mechanize import Browser
b = Browser()
# follow second link with element text matching regular expression
response = b.follow_link(text_regex=re.compile(r"cheese\s*shop"), nr=1)
# Browser passes through unknown attributes (including methods)
# first to the selected HTMLForm (from ClientForm), then to the last response.
# Here we use the former (the method here is __setitem__).
b["cheeses"] = ["mozzarella", "caerphilly"]
response2 = b.submit() # submit current form
response3 = b.back() # back to cheese shop
response4 = b.reload()
for link in b.forms():
# .links() optionally accepts the keyword args of .follow_/.find_link()
for link in b.links(url_regex=re.compile("python.org")):