Module browser :: Class Browser
[show private | hide private]
[frames | no frames]

Class Browser


An automated web browser.
Method Summary
  __init__(self)
  content(self)
Returns a string containing the current data in the page.
  current_form(self)
Returns a HTMLFormElement representing the current form.
  dump_forms(self)
Dump details of all forms on the page.
  field(self, fieldname, fieldvalue)
Change the value in a form field in the currently selected form.
  fieldValues(self)
Returns a dictionary containing the values set in the current form.
  follow_link(self, linkdata)
Direct the Browser to follow a specified link on the current page.
  form(self, formdata)
Choose a form on the page to which further form manipulations (field, submit) will apply.
  get(self, uri, method, data)
get -- have the Browser navigate to a URI.
  submit(self)
Submit the currently selected form.
  uri(self)
Returns a string containing the current URI.

Method Details

content(self)

Returns a string containing the current data in the page.

current_form(self)

Returns a HTMLFormElement representing the current form.

dump_forms(self)

Dump details of all forms on the page. Useful for debugging.

field(self, fieldname, fieldvalue)

Change the value in a form field in the currently selected form. Defaults to the first form on the page if no form has been specified.
Parameters:
fieldname - The name of the field to alter, matching its name attribute.
           (type=string)
fieldvalue - The value to set in the field.
           (type=string)
Raises:
FieldNotFoundError - If you specified a field that is not in the form.

fieldValues(self)

Returns a dictionary containing the values set in the current form.

follow_link(self, linkdata)

Direct the Browser to follow a specified link on the current page.
Parameters:
linkdata - Pass either an integer, a string, or a compiled regex. An integer will follow that link on the page (first link is 1, not 0!). A string will follow the first link it finds with that text therein (as the full string, not a substring). A regex will follow the first link it finds that matches the regex.
           (type=string, int, compiled regex)
Raises:
LinkNotFoundError - If you specified a link that is not on the page (either too high a number, or a string that doesn't match any of the page links).
LinkNoHrefError - If you specified a link that does not have a href attribute (and hence cannot be navigated).

form(self, formdata)

Choose a form on the page to which further form manipulations (field, submit) will apply.
Parameters:
formdata - Pass either an integer or a string. An integer will select that form on the page (first form is 1, not 0!). A string will attempt to select a form by name, matching on the form's name attribute.
           (type=string, int)
Raises:
FormNotFoundError - If you specified a form that is not on the page (either too high a number, or a string that doesn't match any of the page's forms' name attributes).

get(self, uri, method='GET', data=None)

get -- have the Browser navigate to a URI.
Parameters:
uri - the URI to which to navigate.
           (type=string)
method - the HTTP method to use (must be GET or POST).
data - a dictionary of keys and values to send as data to the remote server.
           (type=dictionary)
Raises:
UnknownMethodError - If you passed an unknown HTTP method (must be GET or POST).

submit(self)

Submit the currently selected form.
Raises:
NoFormSpecifiedError - If no form is currently selected.

uri(self)

Returns a string containing the current URI.

Generated by Epydoc 2.0 on Sun Nov 30 09:49:04 2003 http://epydoc.sf.net