Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ANN: mechanize 0.0.1a released

0 views
Skip to first unread message

John J. Lee

unread,
Dec 23, 2003, 9:52:53 AM12/23/03
to
http://wwwsearch.sourceforge.net/mechanize

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
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)

# 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():
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


John

0 new messages