API Reference

browser

Robotic browser

class pyrobot.browser.RoboBrowser(auth=None, parser=None, headers=None, user_agent=None, history=True)[source]

Robotic web browser.

back(n=1)[source]

Go back in browser history.

Parameters:n (int) – Number of pages to go back

Find a click a link by tag, pattern, and/or BeautifulSoup arguments.

Parameters:value – BeautifulSoup tag, string, or regex. If tag, follow its href; if string or regex, search parsed document for match
forward(n=1)[source]

Go forward in browser history.

Parameters:n (int) – Number of pages to go forward
get_form(id=None, *args, **kwargs)[source]

Find form by ID, as well as standard BeautifulSoup arguments.

Parameters:id (str) – Form ID
Returns:BeautifulSoup tag if found, else None
get_forms(*args, **kwargs)[source]

Find forms by standard BeautifulSoup arguments.

Returns:List of BeautifulSoup tags

Find an anchor or button by containing text, as well as standard BeautifulSoup arguments.

Parameters:text – String or regex to be matched in link text
Returns:BeautifulSoup tag if found, else None

Find anchors or buttons by containing text, as well as standard BeautifulSoup arguments.

Parameters:text – String or regex to be matched in link text
Returns:List of BeautifulSoup tags
open(url)[source]

Open a URL.

Parameters:url (str) – URL
submit_form(form)[source]

Submit a form.

Parameters:form (Form) – Filled-out form object
class pyrobot.browser.RoboState(browser, response)[source]

Representation of a browser state. Wraps the browser and response, and lazily parses the response content.

parsed[source]

Lazily parse response content, using HTML parser specified by the browser.

form

HTML forms

class pyrobot.forms.form.Form(parsed)[source]

Representation of an HTML form.

serialize()[source]

Serialize each form field and collect the results in a dictionary of dictionaries. Different fields may serialize their contents to different sub-dictionaries: most serialize to data, but file inputs serialize to files. Sub-dictionary keys should correspond to parameters of requests.Request.

Return dict:Dict-of-dicts of serialized data

fields

HTML form fields

class pyrobot.forms.fields.BaseField(parsed)[source]

Abstract base class for form fields.

class pyrobot.forms.fields.FieldMeta(name, bases, dct)[source]

Multiply inherit from ValueMeta and ABCMeta; classes with this meta- class are automatically assigned a value property and can use methods from ABCMeta (e.g. abstractmethod).

mro() → list

return a type’s method resolution order

register(subclass)

Register a virtual subclass of an ABC.

class pyrobot.forms.fields.ValueMeta(name, bases, dct)[source]

Meta-class that creates a value property on class creation. Classes with this meta-class should define _get_value and optionally _set_value methods.

mro() → list

return a type’s method resolution order

Table Of Contents

Related Topics

This Page

Fork me on GitHub