ANN: mechanize 0.0.7a released (original) (raw)

John J. Lee jjl@pobox.com
09 Jan 2004 20:04:11 +0000


http://wwwsearch.sourceforge.net/mechanize/

This is an alpha release.

Changes since 0.0.2a:

Requires Python 2.2, ClientCookie >= 0.4.17 (note version!), ClientForm 0.1.x and pullparser >= 0.0.4b.

Stateful programmatic web browsing, after Andy Lester's Perl module WWW::Mechanize.

Example:

import re from mechanize import Browser

b = Browser() b.open("http://www.example.com/")

follow second link with element text matching regular expression

response = b.follow_link(text_regex=re.compile(r"cheese\s*shop"), nr=1)

b.select_form(name="order")

Browser passes through unknown attributes (including methods)

to the selected HTMLForm (from ClientForm).

b["cheeses"] = ["mozzarella", "caerphilly"] # (the method here is setitem) response2 = b.submit() # submit current form

response3 = b.back() # back to cheese shop response4 = b.reload()

for link in b.forms(): print form

.links() optionally accepts the keyword args of .follow_/.find_link()

for link in b.links(url_regex=re.compile("python.org")): print link b.follow_link(link) # takes EITHER Link instance OR keyword args b.back()

John